PyGreSQL - Python interface for PostgreSQL

PyGreSQL version 4.1.1



PostgreSQL is a highly scalable, SQL compliant, open source object-relational database management system. With more than 15 years of development history, it is quickly becoming the de facto database for enterprise level open source solutions. Best of all, PostgreSQL's source code is available under the most liberal open source license: the BSD license.

Python Python is an interpreted, interactive, object-oriented programming language. It is often compared to Tcl, Perl, Scheme or Java. Python combines remarkable power with very clear syntax. It has modules, classes, exceptions, very high level dynamic data types, and dynamic typing. There are interfaces to many system calls and libraries, as well as to various windowing systems (X11, Motif, Tk, Mac, MFC). New built-in modules are easily written in C or C++. Python is also usable as an extension language for applications that need a programmable interface. The Python implementation is copyrighted but freely usable and distributable, even for commercial use.

PyGreSQL is a Python module that interfaces to a PostgreSQL database. It embeds the PostgreSQL query library to allow easy use of the powerful PostgreSQL features from a Python script.

PyGreSQL is developed and tested on a NetBSD system, but it should also run on most other platforms where PostgreSQL and Python is running. It is based on the PyGres95 code written by Pascal Andre ( D'Arcy ( renamed it to PyGreSQL starting with version 2.0 and serves as the "BDFL" of PyGreSQL.

The current version PyGreSQL 4.1 needs PostgreSQL 8.3 and Python 2.5 or above.

Where to get ... ?

Download PyGreSQL here

The released version of the source code is available at
You can also check the latest pre-release version at
A Linux RPM can be picked up from
A NetBSD package is available in their pkgsrc collection
A FreeBSD package is available in their ports collection
A Win32 package for various Python versions is available at
You can also find PyGreSQL on the Python Package Index at

Distribution files

pgmodule.c the C Python module (_pg) the "classic" PyGreSQL module DB-SIG DB-API 2.0 compliant API wrapper for PygreSQL

documentation directory

Contains: readme.txt, announce.txt, install.txt, changelog.txt, future.txt, pg.txt and pgdb.txt.

All text files are in ReST format, so HTML versions can be easily created with from docutils.


demos directory

Contains:,, and

The samples here have been taken from the PostgreSQL manual and were used for module testing. They demonstrate some PostgreSQL features.


You will find the installing instructions in install.txt.

Information and support

For support


Contact the PyGreSQL mailing list concerning PyGreSQL 2.0 and up.

If you would like to proposes changes, please join the PyGreSQL mailing list and send context diffs there.

See to join the mailing list.

Please note that messages to individual developers will generally not be answered directly. All questions, comments and code changes must be submitted to the mailing list for peer review and archiving purposes.

PyGreSQL programming information

You may either choose to use the "classic" PyGreSQL interface provided by the pg module or else the newer DB-API 2.0 compliant interface provided by the pgdb module.

DB-API 2.0 (Python Database API Specification v2.0) is a specification for connecting to databases (not only PostGreSQL) from Python that has been developed by the Python DB-SIG in 1999.

The programming information is available in the files pg.txt and pgdb.txt.

Note that PyGreSQL is not thread-safe on the connection level. Therefore we recommend using DBUtils <> for multi-threaded environments, which supports both PyGreSQL interfaces.

ChangeLog and Future

The ChangeLog with past changes is in the file changelog.txt.

A to do list and wish list is in the file future.txt.