在cx_Oracle(或通常是Oracle)中,是否可以为每个查询分配一个游标,或者在多个查询中重用游标.
def getSomeData(curs): # case 1: pass in a cursor,which is generally curs.execute('select ...') # reused across queries return curs.fetchall() def getSomeData(conn): # case 2: pass in a connection,allocate curs=conn.cursor() # a cursor for this query curs.execute('select ...') return curs.fetchall()
当然,这两种方法都返回相同的数据.