Simple psycopg2 setup


Abbreviated from psycopg2 tutorial.

import psycopg2

# host and port are default 'localhost' and 6432.
# password is ideally stored in .pgpass
conn = psycopg2.conn("dbname='' user=''")
cursor = conn.cursor()

cursor.execute("select column from table")
row = cursor.fetchall()

for row in rows:
    print(row)

conn.close()