Created
February 25, 2020 22:48
-
-
Save fgregg/e839dcc0305909a3bdb3a0a3cc56bd61 to your computer and use it in GitHub Desktop.
offset batch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def batched_result_generator(cur): | |
offset = 0 | |
batchsize = 100 | |
exhausted = False | |
while not exhausted: | |
results = cur.execute('select ... from offset = ? limit = ?', (offset, batchsize)).fetchall() | |
if len(results) < batchsize: | |
exhausted = True | |
for row in results: | |
yield row | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment