如何在python中安装PostgreSQL函数?
我想通过Python修改PostgreSQL数据库。比如在Python中输入信息。它将自动处理和分类PSQL数据库中的数据。怎么做 简单的问题:)是PostgreSQL的可靠包装。从文档中:如何在python中安装PostgreSQL函数?,python,database,postgresql,Python,Database,Postgresql,我想通过Python修改PostgreSQL数据库。比如在Python中输入信息。它将自动处理和分类PSQL数据库中的数据。怎么做 简单的问题:)是PostgreSQL的可靠包装。从文档中: DSN = 'dbname=test' ## don't modify anything below this line (except for experimenting) class SimpleQuoter(object): def sqlquote(x=None): re
DSN = 'dbname=test'
## don't modify anything below this line (except for experimenting)
class SimpleQuoter(object):
def sqlquote(x=None):
return "'bar'"
import sys
import psycopg2
if len(sys.argv) > 1:
DSN = sys.argv[1]
print("Opening connection using dsn:", DSN)
conn = psycopg2.connect(DSN)
print("Encoding for this connection is", conn.encoding)
curs = conn.cursor()
curs.execute("SELECT 1 AS foo")
print(curs.fetchone())
curs.execute("SELECT 1 AS foo")
print(curs.fetchmany())
curs.execute("SELECT 1 AS foo")
print(curs.fetchall())
conn.rollback()
sys.exit(0)
curs.execute("SELECT 1 AS foo", async=1)
curs.execute("SELECT %(foo)s AS foo", {'foo':'bar'})
curs.execute("SELECT %(foo)s AS foo", {'foo':None})
curs.execute("SELECT %(foo)f AS foo", {'foo':42})
curs.execute("SELECT %(foo)s AS foo", {'foo':SimpleQuoter()})
欢迎访问stackoverflow.com。请花些时间阅读,特别是命名和。也请阅读好的问题。最后,请学习如何创建一个不太确定您的要求。如果你想知道安装哪个包来连接python和postgresql,它就是psycopg2。没有办法“自动”完成你写的东西,谢谢大家的回答。如果有点混乱,很抱歉。但我的想法得到了澄清:)