skip to navigation
skip to content

py-postgresql 1.1.0

PostgreSQL driver and tools library.

Package Documentation


v1.1.0 requires Python 3.3 or the ipaddress module from 3.3 to be copied to the python3.2.

py-postgresql is a set of Python modules providing interfaces to various parts of PostgreSQL. Notably, it provides a pure-Python driver + C optimizations for querying a PostgreSQL database.


  • Prepared Statement driven interfaces.
  • Cluster tools for creating and controlling a cluster.
  • Support for most PostgreSQL types: composites, arrays, numeric, lots more.
  • COPY support.

Sample PG-API Code:

>>> import postgresql
>>> db ='pq://user:password@host:port/database')
>>> db.execute("CREATE TABLE emp (emp_first_name text, emp_last_name text, emp_salary numeric)")
>>> make_emp = db.prepare("INSERT INTO emp VALUES ($1, $2, $3)")
>>> make_emp("John", "Doe", "75,322")
>>> with db.xact():
...  make_emp("Jane", "Doe", "75,322")
...  make_emp("Edward", "Johnson", "82,744")

There is a DB-API 2.0 module as well:


However, PG-API is recommended as it provides greater utility.

Once installed, try out the pg_python console script:

$ python3 -m postgresql.bin.pg_python -h localhost -p port -U theuser -d database_name

If a successful connection is made to the remote host, it will provide a Python console with the database connection bound to the db name.


py-postgresql is not yet another PostgreSQL driver, it’s been in development for years. py-postgresql is the Python 3 port of the pg_proboscis driver and integration of the other pg/python projects.

File Type Py Version Uploaded on Size (md5) Source 2012-10-08 248KB
  • Downloads (All Versions):
  • 19 downloads in the last day
  • 617 downloads in the last week
  • 3339 downloads in the last month