Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import psycopg2
- # make a connection
- try:
- conn = psycopg2.connect(database='postgres', user='postgres', password='economicalchinchillacorndog', host='localhost')
- cur = conn.cursor()
- except:
- print('Database Connection Failed')
- raise
- # run a SQL query
- cur.execute('SELECT * FROM orders')
- # iterate through the results
- for item in cur.fetchall():
- print(item)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement