Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import psycopg2
- try:
- conn = pyscopg2.connect(database='wildlife', user='postgres', password='P@$$w0rd', host='localhost' port='5432')
- print "successfully connected to database"
- except:
- print "connection Failure"
- cur = conn.cursor()
- cur.execute("SELECT ID,NAME,LIVES,WEIGHT,LEGS,CLASS,NUMBER,CATEGORY FROM CAGE";)
- rows = cur.fetchall()
- for row in rows:
- print "ID = ", row[0]
- print "NAME = ", row[1]
- print "LIVES = ", row[2], "n"
- conn.close()
- Error executing SQL statement. ERROR: syntax error at or near "psycopg2"
Add Comment
Please, Sign In to add comment