postgresql的驱动程序python

Yag*_*iro 6 python postgresql driver

哪个是连接到postgresql的python中最好的驱动程序?

有几种可能性,http://wiki.postgresql.org/wiki/Python但我不知道哪个是最好的选择

任何的想法?

Sky*_*and 12

psycopg2是每个人都使用CPython的人.但是对于PyPy,你需要看看纯Python的.


Don*_*ion 10

我推荐sqlalchemy - 它提供了很大的灵活性,并且具有复杂的界面.

此外,它不仅限于postgresql.

教程中的无耻c&p :

from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker

# an Engine, which the Session will use for connection
# resources
some_engine = create_engine('postgresql://scott:tiger@localhost/')

# create a configured "Session" class
Session = sessionmaker(bind=some_engine)

# create a Session
session = Session()

# work with sess
myobject = MyObject('foo', 'bar')
session.add(myobject)
session.commit()
Run Code Online (Sandbox Code Playgroud)

由于评论(更新)的澄清:

sqlalchemy本身不是驱动程序,而是一个所谓的对象关系映射器.它提供并包含它自己的驱动程序,在postgresql-case中是libpq,它本身包含在psycopg2中.

因为OP强调他想要" 连接到postgresql" 的"最好的驱动程序" 我指出sqlalchemy,即使它可能是一个错误的答案术语明智,但意图明智我觉得它是更有用的.

即使我不喜欢"分裂"的舞蹈,我仍然最终做到了这一点,因为感觉压力来自我的回答.

对于因我的诽谤而引起的任何烦恼,我道歉.