2014-06-22 60 views
3

我想从txpostgres中的存储过程获取光标。 Psycopg2有一个命名游标,它工作正常。但txpostgres中没有curs = conn.cursor('name')声明。txpostgres存储过程返回光标

有没有另一种方法来得到它?

回答

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)