基本
import psycopg2
cxn = psycopg2.connect(user='postgres',password='root')
cur = cxn.cursor()
cur.execute('SELECT * FROM pg_database')
rows = cur.fetchall()
for i in rows:
print i
cur.close()
cxn.commit()
cxn.close()
基本链接查询