Skip to content

Commit

Permalink
Fixed #2662 -- Changed dictfetchmany and dictfetchall to return itera…
Browse files Browse the repository at this point in the history
…tors,

rather than a list, in order to save memory. Patch from Simon Willison.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@3783 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
malcolmt committed Sep 22, 2006
1 parent 4b5f0e2 commit 4f63ce5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions django/db/backends/util.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -110,9 +110,11 @@ def dictfetchone(cursor):
def dictfetchmany(cursor, number): def dictfetchmany(cursor, number):
"Returns a certain number of rows from a cursor as a dict" "Returns a certain number of rows from a cursor as a dict"
desc = cursor.description desc = cursor.description
return [_dict_helper(desc, row) for row in cursor.fetchmany(number)] for row in cursor.fetchmany(number):
yield _dict_helper(desc, row)


def dictfetchall(cursor): def dictfetchall(cursor):
"Returns all rows from a cursor as a dict" "Returns all rows from a cursor as a dict"
desc = cursor.description desc = cursor.description
return [_dict_helper(desc, row) for row in cursor.fetchall()] for row in cursor.fetchall():
yield _dict_helper(desc, row)

0 comments on commit 4f63ce5

Please sign in to comment.