Created
February 26, 2016 00:34
-
-
Save robsmith1776/1447456649e0f5ad81dd to your computer and use it in GitHub Desktop.
ResultIter - for pymssql
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 ResultIter(cursor, arraysize=1000): | |
'An iterator that uses fetchmany to keep memory usage down' | |
while True: | |
results = cursor.fetchmany(arraysize) | |
if not results: | |
break | |
for result in results: | |
yield result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
from http://code.activestate.com/recipes/137270-use-generators-for-fetching-large-db-record-sets/