Gestire ResultSet grandi

Introduzione ai database in Python

Jason Myers

Co-Author of Essential SQLAlchemy and Software Engineer

Gestire ResultSet grandi

  • fetchmany() permette di indicare quante righe elaborare
  • Possiamo iterare su fetchmany()
  • Restituisce una lista vuota quando non ci sono più record
  • Alla fine chiudiamo il ResultProxy
Introduzione ai database in Python

Recuperare molte righe

while more_results:

partial_results = results_proxy.fetchmany(50)
if partial_results == []: more_results = False
for row in partial_results: state_count[row.state] += 1
results_proxy.close()
Introduzione ai database in Python

Facciamo pratica!

Introduzione ai database in Python

Preparing Video For Download...