Guest User

Untitled

a guest
Oct 23rd, 2018
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. import psycopg2
  2.  
  3. try:
  4. conn = pyscopg2.connect(database='wildlife', user='postgres', password='P@$$w0rd', host='localhost' port='5432')
  5. print "successfully connected to database"
  6.  
  7. except:
  8. print "connection Failure"
  9.  
  10. cur = conn.cursor()
  11. cur.execute("SELECT ID,NAME,LIVES,WEIGHT,LEGS,CLASS,NUMBER,CATEGORY FROM CAGE";)
  12. rows = cur.fetchall()
  13. for row in rows:
  14. print "ID = ", row[0]
  15. print "NAME = ", row[1]
  16. print "LIVES = ", row[2], "n"
  17.  
  18. conn.close()
  19.  
  20. Error executing SQL statement. ERROR: syntax error at or near "psycopg2"
Add Comment
Please, Sign In to add comment