1 2 3 4 5 6 7 8 9 10 11 12 | def iter_fetchmany(cursor, size=100):
"""
Handles the awkwardness of iterating using fetchmany, and exposes all records as a (generated) iterable.
Assumes django.db is the connection for the given cursor. FIXME for multi-db support.
"""
from django.db import connection
rowset_iter = iter((lambda: cursor.fetchmany(size)),
connection.features.empty_fetchmany_value)
for rows in rowset_iter:
for row in rows:
yield row
|
More like this
- Memory efficient Django Queryset Iterator by WoLpH 3 years, 2 months ago
- ByteSplitterField by Lacour 1 year, 8 months ago
- WorldIP - access to IP database over API by Alrond 4 years, 8 months ago
- Validate request params without custom form by xiaoym 3 weeks, 5 days ago
- Function/Stored Procedure Manager by axiak 5 years, 11 months ago
Comments