txpostgres存储过程返回游标

时间:2014-06-22 09:59:34

标签: python postgresql twisted

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

还有另一种方法可以获得吗?

1 个答案:

答案 0 :(得分:1)

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)