资 源 简 介
ocpgdb is a Python DB-API 2 (aka pep-0249) adapter for PostgreSQL. The code is simple, modular and extensible, with most of the intelligence implemented in Python with only a small C wrapper around libpq. The module is used in several production systems, and while there is little documentation at this stage, most things work as described in pep-0249.
Unlike most Python PG adapters, this module uses the newer binary PG protocol 3 - in many cases this protocol is faster and safer, although the protocol is less forgiving of implicit type-casting. As an example, other adapters will accept:
curs.execute("SELECT * FROM foo WHERE bah > %s", "2006-1-1")
whereas protocol 3 requires:
curs.execute("SELECT * FROM foo WHERE bah > %s", datetime.datetime(2006,1,1))
or an explicit cast:
curs.execute("SELECT * FROM foo WHERE bah