python如何链接pgsql???

python如何链接pgsql???

谢谢!!!
从pyPgSQL的readme里拷出来的

[Copy to clipboard] [ - ]
CODE:
>>> from pyPgSQL import PgSQL
>>> cx = PgSQL.connect(database="mydb", client_encoding="utf-8", unicode_results=1)
>>> cu = cx.cursor()
>>> cu.execute("set client_encoding to unicode")
>>> cu.execute("insert into test(v) values (%s)", (u'\x99sterreich',))
>>> cu.execute("select v from test")
>>> cu.fetchone()
[u'\x99sterreich']
>>>

偶用pygresql
#apt-get install python-pygresql

>>>import pydb
>>>conn=pydb.connect(host="192.168.0.1",database="mydb", user="name",password="***")

其他用法和楼上的相同
经典,不错.