summaryrefslogtreecommitdiff
path: root/lib/extras.py
diff options
context:
space:
mode:
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>2011-04-26 19:26:19 +0100
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>2011-04-26 19:26:19 +0100
commitc61ec094a38ce2b0ecc3c6673065766f7ad9ea32 (patch)
treefa9bf4495963b99c8b55cd3d60dc5281c5f73b19 /lib/extras.py
parentffa7a62b9313b52af0c70f61b888703de1491777 (diff)
downloadpsycopg2-c61ec094a38ce2b0ecc3c6673065766f7ad9ea32.tar.gz
Don't fetch all the records iterating a NamedTuple cursor on a named cursor
Diffstat (limited to 'lib/extras.py')
-rw-r--r--lib/extras.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/extras.py b/lib/extras.py
index dcbd65e..1a4b730 100644
--- a/lib/extras.py
+++ b/lib/extras.py
@@ -304,7 +304,14 @@ class NamedTupleCursor(_cursor):
return [nt(*t) for t in ts]
def __iter__(self):
- return iter(self.fetchall())
+ # Invoking _cursor.__iter__(self) goes to infinite recursion,
+ # so we do pagination by hand
+ while 1:
+ recs = self.fetchmany(self.itersize)
+ if not recs:
+ return
+ for rec in recs:
+ yield rec
try:
from collections import namedtuple