대용량 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...