sql >> Base de Datos >  >> RDS >> Oracle

Obtener grandes datos de Oracle en Python

Deberías usar cur.fetchmany() en su lugar. Obtendrá fragmentos de filas definidas por arraysise (256)

Código Python:

def chunks(cur): # 256
    global log, d
    while True:
        #log.info('Chunk size %s' %  cur.arraysize, extra=d)
        rows=cur.fetchmany()

        if not rows: break;
        yield rows

Luego haga su procesamiento en un bucle for;

for i, chunk  in enumerate(chunks(cur)):
            for row in chunk:
                     #Process you rows here

Así es exactamente como lo hago en mi TableHunter for Oracle .