Simple psycopg2 setup
January 17th, 2025
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()