you can download current stable Psycopg 2.4.6 here or you can use PyPI(Python Package Install) with
if you download package, you can install it with
python setup.py install command. dont forget that you will probably need python-dev and libpq-dev packages.
The pg_config must be available in your path, or alternatively you
must specify its full path in the setup.cfg file.
after installation, you can call it:
and example code from Postgresql Wiki:
conn = psycopg2.connect("dbname='template1' user='dbuser' host='localhost'
print "I am unable to connect to the database"
cur = conn.cursor()
cur.execute("""SELECT datname from pg_database""")
rows = cur.fetchall()
print "\nShow me the databases:\n"
for row in rows:
print " ", row
i hope it helps you...