PostgreSQL驱动程序和工具库。
py-postgresql的Python项目详细描述
py postgresql是一组python模块,为各个部分提供接口 关于PostgreSQL。值得注意的是,它为 查询PostgreSQL数据库。
http://python.projects.postgresql.org
功能:
- Prepared Statement driven interfaces.
- Cluster tools for creating and controlling a cluster.
- Support for most PostgreSQL types: composites, arrays, numeric, lots more.
- COPY support.
PG-API代码示例:
>>> import postgresql >>> db = postgresql.open('pq://user:password@host:port/database') >>> db.execute("CREATE TABLE emp (emp_first_name text, emp_last_name text, emp_salary numeric)") >>> make_emp = db.prepare("INSERT INTO emp VALUES ($1, $2, $3)") >>> make_emp("John", "Doe", "75,322") >>> with db.xact(): ... make_emp("Jane", "Doe", "75,322") ... make_emp("Edward", "Johnson", "82,744") ...
还有一个DB-API 2.0模块:
postgresql.driver.dbapi20
但是,建议使用PG-API,因为它提供了更大的实用性。
安装后,请尝试pg_python控制台脚本:
$ python3 -m postgresql.bin.pg_python -h localhost -p port -U theuser -d database_name
如果成功连接到远程主机,它将提供一个python 数据库连接绑定到db名称的控制台。
历史记录
py postgresql还不是另一个postgresql驱动程序,它是为 年。py postgresql是pg_proboscis驱动程序的python 3端口,并且 其他pg/python项目的集成。