Advertisement
Guest User

Untitled

a guest
Nov 1st, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. import psycopg2
  2.  
  3. # make a connection
  4. try:
  5. conn = psycopg2.connect(database='postgres', user='postgres', password='economicalchinchillacorndog', host='localhost')
  6. cur = conn.cursor()
  7. except:
  8. print('Database Connection Failed')
  9. raise
  10.  
  11. # run a SQL query
  12. cur.execute('SELECT * FROM orders')
  13.  
  14. # iterate through the results
  15. for item in cur.fetchall():
  16. print(item)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement