Psycopg 是 Python 语言的 PostgreSQL 数据库接口。 它的主要优势在于完全支持Python DB API 2.0,以及安全的多线程支持。它适用于随时创建、销毁大量游标的、和产生大量并发INSERT、UPDATE操作的多线程数据库应用。Psycopg包内含 ZPsycopgDA,一个Zope数据库接口。
特性:
●对libpq v3协议的完全支持;
●COPY TO/COPY FROM语句;
●对所有基本Python类型的支持:字符串(支持Unicode)、整型、长整型、浮点型、缓冲区(二进制对象)、布尔型(逻辑型)、mx.DateTime和内置的日期时间型。
●还支持Unicode查询,和Python列表型与PostgreSQL数组类型的映射。
新版本支持 Python 3.1 和 3.2 版本,实现了高效的命名游标,更好的支持 Python 和 PostgreSQL 的大对象转换;修复了不少bug。
更新日志:
Added support for Python 3.1 and 3.2. The conversion has also brought several improvements:
Added 'b' and 't' mode to large objects: write can deal with both bytes strings and unicode; read can return either bytes strings or decoded unicode.
COPY sends Unicode data to files implementing 'io.TextIOBase'.
Improved PostgreSQL-Python encodings mapping.
Added a few missing encodings: EUC_CN, EUC_JIS_2004, ISO885910, ISO885916, LATIN10, SHIFT_JIS_2004.
Dropped repeated dictionary lookups with unicode query/">parameters.
Improvements to the named cusors:
More efficient iteration on named cursors, fetching 'itersize' records at time from the backend.
The named cursors name can be an invalid identifier.
Improvements in data handling:
Added 'register_composite()' function to cast PostgreSQL composite types into Python tuples/namedtuples.
Adapt types 'bytearray' (from Python 2.6), 'memoryview' (from Python 2.7) and other objects implementing the "Revised Buffer Protocol" to 'bytea' data type.
The 'hstore' adapter can work even when the data type is not installed in the 'public' namespace.
Raise a clean exception instead of returning bad data when receiving bytea in 'hex' format and the client libpq can't parse them.
Empty lists correctly roundtrip Python -> PostgreSQL -> Python.
Other changes:
'cursor.description' is provided as named tuples if available.
The build script refuses to guess values if 'pg_config' is not found.
Connections and cursors are weakly referenceable.
Bug fixes:
Fixed adaptation of None in composite types (ticket #26). Bug report by Karsten Hilbert.
Fixed several reference leaks in less common code paths.
Fixed segfault when a large object is closed and its connection no more available.
Added missing icon to ZPsycopgDA package, not available in Zope 2.12.9 (ticket #30). Bug report and patch by Pumukel.
Fixed conversion of negative infinity (ticket #40). Bug report and patch by Marti Raudsepp.
下载地址:http://www.psycopg.org/psycopg/tarballs/PSYCOPG-2-4/psycopg2-2.4.tar.gz