Python (PyGreSQL)

PyGreSQL is a Python interface to the PostgreSQL database. It was written by D’Arcy J.M. Cain and was based heavily on code written by Pascal Andre.

PyGreSQL is implemented as three parts:

C shared module: _pg.so

Two Python wrappers: pg.py and pgdb.py

Compiling PyGreSQL

In the directory containing pgmodule.c, run the following command:

cc -fpic -shared -o _pg.so -I[pyInc] --I[pgInc] --L[pgLib] --lpq pgmodule.c 

Compile-time options include the following:

[pyInc] = Python include path (Python.h)

[pgInc] = PostgreSQL include path (Postgres.h)

[pgLib] = PostgreSQL libraries path (libpq.so /libpq.a)

Some of the following keywords can be specified:

-DNO_DEF_VAR Disable default variables support.
-DNO_DIRECT Disable direct access ...

Get PostgreSQL Essential Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.