Ticket #2662: util.py.diff

File util.py.diff, 751 bytes (added by Simon Willison, 18 years ago)

Patch changing dictfetchmany and dictfetchall to be generators

  • django/db/backends/util.py

     
    110110def dictfetchmany(cursor, number):
    111111    "Returns a certain number of rows from a cursor as a dict"
    112112    desc = cursor.description
    113     return [_dict_helper(desc, row) for row in cursor.fetchmany(number)]
     113    for row in cursor.fetchmany(number):
     114        yield _dict_helper(desc, row)
    114115
    115116def dictfetchall(cursor):
    116117    "Returns all rows from a cursor as a dict"
    117118    desc = cursor.description
    118     return [_dict_helper(desc, row) for row in cursor.fetchall()]
     119    for row in cursor.fetchall():
     120        yield _dict_helper(desc, row)
Back to Top