大規模なResultSetの処理

Pythonで学ぶデータベース入門

Jason Myers

Co-Author of Essential SQLAlchemy and Software Engineer

大規模なResultSetへの対応

  • fetchmany()で処理する行数を指定できます
  • fetchmany()をループで回します
  • これ以上なければ空リストを返します
  • 最後にResultProxyを閉じます
Pythonで学ぶデータベース入門

複数行の取得

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()
Pythonで学ぶデータベース入門

演習に進みましょう

Pythonで学ぶデータベース入門

Preparing Video For Download...