def enumerate_query_by_limit(q, limit=<NUM_LIT:1000>):
for offset in count(<NUM_LIT:0>, limit):<EOL><INDENT>r = q.offset(offset).limit(limit).all()<EOL>for row in r:<EOL><INDENT>yield row<EOL><DEDENT>if len(r) < limit:<EOL><INDENT>break<EOL><DEDENT><DEDENT>
Enumerate over SQLAlchemy query object ``q`` and yield individual results
fetched in batches of size ``limit`` using SQL LIMIT and OFFSET.