Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Branch: master
Fetching contributors…

Cannot retrieve contributors at this time

83 lines (53 sloc) 2.324 kB
* pgasync *
An asyncronous, twisted-based PostgreSQL client library
Written by Jamie Turner <>
pgasync fully conforms to the DB 2.0 API.
In a single, dedicated thread, it generally runs about 1.8x as slow as syncronous
psycopg, which is written entirely in C.
However, using adbapi (psycopg's twisted.enterprise w/the overhead of threading),
it runs slightly faster than psycopg + enterprise at low load,
and seems to be *much* more stable and scalable under heavy load.
All execute(), exFetch(), and fetch*() methods return a
twisted.internet.defer.Deferred. Queries will be queued, so feel free to
ignore these deferreds if you're not interested in the results: keep adding
more queries.
The one exception is connection.cursor(). No queries should execute
until this function's deferred calls back.
paramstyle is pyformat. types are provided.
Pooling/persistence happens, and the pool grows/shrinks based on activity.
Twisted 1.3
Python 2.3+ (for datetime module)
PostgreSQL 7.4+ (protocol version 3.0)
# python install
Read the notes on the website:
cur = db.cursor()
# 1st arg 'rows' gets added; return value of async function
def printRows(rows,cur):
print rows
# execute + fetch with one callback
cur.exFetch("SELECT * FROM users WHERE username = %(matchname)s",{matchname : "pete"}).addCallback(fetch,cur)
examples/ directory of this distribution.
It utillizes a Pyrex file to take care of one processor intesive thing. This
cache.c file is pre-built for you and shipped with the distribution. The cache.pyx
file is available in case you run into problems. Set REBUILD_PYREX to True if you
want the pyx to be reprocessed (you'll need pyrex).
Also: it builds a simple convert.c file that has some convenient byte order swapping
functions for the pyx. This hasn't been tested on anything but FreeBSD and Linux
at the moment. If there's a different header file needed for htonl/htons for your
system, please let me know.
Cleartext and MD5 auth are supported.
Jump to Line
Something went wrong with that request. Please try again.