diff options
Diffstat (limited to 'lib/extras.py')
-rw-r--r-- | lib/extras.py | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/lib/extras.py b/lib/extras.py index aa7bc87..870b5ca 100644 --- a/lib/extras.py +++ b/lib/extras.py @@ -310,14 +310,17 @@ class NamedTupleCursor(_cursor): return [nt(*t) for t in ts] def __iter__(self): - # Invoking _cursor.__iter__(self) goes to infinite recursion, - # so we do pagination by hand + it = _cursor.__iter__(self) + t = it.next() + + nt = self.Record + if nt is None: + nt = self.Record = self._make_nt() + + yield nt(*t) + while 1: - recs = self.fetchmany(self.itersize) - if not recs: - return - for rec in recs: - yield rec + yield nt(*it.next()) try: from collections import namedtuple |