Práce s velkými ResultSety

Introduction to Databases in Python

Jason Myers

Co-Author of Essential SQLAlchemy and Software Engineer

Práce s velkými ResultSety

  • fetchmany() umožňuje určit počet řádků, se kterými chceme pracovat
  • Přes fetchmany() lze iterovat
  • Vrátí prázdný seznam, pokud již nejsou žádné záznamy
  • Poté je nutné ResultProxy uzavřít
Introduction to Databases in Python

Načítání mnoha řádků

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()
Introduction to Databases in Python

Pojďme si procvičit!

Introduction to Databases in Python

Preparing Video For Download...