Skip to content

Commit

Permalink
fetch 10k rows at the time
Browse files Browse the repository at this point in the history
  • Loading branch information
kukicola committed Feb 18, 2024
1 parent f069b28 commit eb8ba6e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/sql2csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,13 @@ def execute_query(cursor, query):
def fetch_rows(cursor):
""" Fetch and yield rows """

for row in cursor.fetchall():
yield row
while True:
rows = cursor.fetchmany(10000)
if not rows:
break

for row in rows:
yield row


def fetch_headers(cursor):
Expand Down

0 comments on commit eb8ba6e

Please # to comment.