iter_fetchmany

 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

  1. Memory efficient Django Queryset Iterator by WoLpH 3 years, 2 months ago
  2. ByteSplitterField by Lacour 1 year, 8 months ago
  3. WorldIP - access to IP database over API by Alrond 4 years, 8 months ago
  4. Validate request params without custom form by xiaoym 3 weeks, 5 days ago
  5. Function/Stored Procedure Manager by axiak 5 years, 11 months ago

Comments

(Forgotten your password?)