A Pure-Python PostgreSQL Driver
Python Shell
Latest commit 46a7e8f Oct 13, 2016 @tlocke tlocke Add --sign to release command in README
This is to sign the release.



pg8000 is a pure-Python PostgreSQL driver that complies with DB-API 2.0. The driver communicates with the database using the PostgreSQL Frontend/Backend Protocol.

CircleCI Build Status: CircleCI


Regression Tests

The easiest way to run the regression tests is using a prebuilt Docker image that contains all of the supported versions of Python, Jython, PyPy, and PostgreSQL, ready-to-run. To use this, just mount your source directory (where you checked out pg8000 to) onto the image in /home/postgres/pg8000-src, and then run the mfenniak/pg8000-test-env image. Here's a simple command-line:

docker run -v `pwd`:/home/postgres/pg8000-src mfenniak/pg8000-test-env

If you don't have Docker, or want to run the tests in a different environment, install tox:

pip install tox

then install all the supported Python versions (using the APT Repository if you're using Ubuntu). Install all the currently supported versions of PostgreSQL (using the APT Repository if you're using Ubuntu). Then for each of them, enable the hstore extension by running the SQL command:

create extension hstore;

and add a line to pg_hba.conf for the various authentication options, eg.

host    pg8000_md5      all               md5
host    pg8000_gss      all               gss
host    pg8000_password all               password
host    all             all               trust

Set the following environment variables for the databases, for example:

export PG8000_TEST_NAME="PG8000_TEST_9_5"
export PG8000_TEST_9_1="{'user': 'postgres', 'password': 'pw', 'port': 5435}"
export PG8000_TEST_9_2="{'user': 'postgres', 'password': 'pw', 'port': 5434}"
export PG8000_TEST_9_3="{'user': 'postgres', 'password': 'pw', 'port': 5433}"
export PG8000_TEST_9_4="{'user': 'postgres', 'password': 'pw', 'port': 5432}"
export PG8000_TEST_9_5="{'user': 'postgres', 'password': 'pw', 'port': 5431}"

then run tox from the pg8000 directory:


Performance Tests

To run the performance tests from the pg8000 directory:

python -m pg8000.tests.performance

Stress Test

There's a stress test that is run by doing:

python ./multi

The idea is to set shared_buffers in postgresql.conf to 128kB, and then run the stress test, and you should get no unpinned buffers errors.

Building The Documentation

The docs are written using Sphinx. To build them, install sphinx:

pip install sphinx

Then type:

python setup.py build_sphinx

and the docs will appear in build/sphinx/html.

Doing A Release Of pg8000

Run tox to make sure all tests pass, then update doc/release_notes.rst then do:

git tag -a x.y.z -m "version x.y.z"
python setup.py register sdist bdist_wheel upload build_sphinx upload_docs --sign