From 4f63ce5b4a625c15718c676f5efb78e0ffa282f5 Mon Sep 17 00:00:00 2001 From: Malcolm Tredinnick Date: Fri, 22 Sep 2006 02:36:50 +0000 Subject: [PATCH] Fixed #2662 -- Changed dictfetchmany and dictfetchall to return iterators, 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 --- django/db/backends/util.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/django/db/backends/util.py b/django/db/backends/util.py index 88318941c8..3ec1b41485 100644 --- a/django/db/backends/util.py +++ b/django/db/backends/util.py @@ -110,9 +110,11 @@ def dictfetchone(cursor): def dictfetchmany(cursor, number): "Returns a certain number of rows from a cursor as a dict" 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): "Returns all rows from a cursor as a dict" desc = cursor.description - return [_dict_helper(desc, row) for row in cursor.fetchall()] + for row in cursor.fetchall(): + yield _dict_helper(desc, row)