gpt4 book ai didi

python - txpostgres 存储过程返回游标

转载 作者:行者123 更新时间:2023-11-28 18:42:39 25 4
gpt4 key购买 nike

我正在尝试从 txpostgres 中的存储过程中获取游标。Psycopg2 有一个命名的游标,可以正常工作。但是txpostgres中没有curs = conn.cursor('name')语句。

还有其他方法吗?

最佳答案

txpostgres 没有命名游标功能。但是,psycopg2 的命名游标只是 PostgreSQL's cursors 的便利包装器。 .我对存储过程没有太多经验,但这里有一个简单查询的示例:

@inlineCallbacks
def transaction(cursor):
yield cursor.execute('mycursor CURSOR FOR SELECT bigtable')
yield cursor.execute('FETCH ALL FROM mycursor')
data = yield cursor.fetchall()

conn.runInteraction(transaction)

关于python - txpostgres 存储过程返回游标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24350136/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com