Turn ResultIter class into Python 3 iterator
This commit is contained in:
parent
23e484cbed
commit
5d3e8b90bf
@ -31,14 +31,14 @@ class ResultIter(object):
|
|||||||
|
|
||||||
def _next_rp(self):
|
def _next_rp(self):
|
||||||
try:
|
try:
|
||||||
self.rp = self.result_proxies.next()
|
self.rp = next(self.result_proxies)
|
||||||
self.count += self.rp.rowcount
|
self.count += self.rp.rowcount
|
||||||
self.keys = self.rp.keys()
|
self.keys = self.rp.keys()
|
||||||
return True
|
return True
|
||||||
except StopIteration:
|
except StopIteration:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def next(self):
|
def __next__(self):
|
||||||
row = self.rp.fetchone()
|
row = self.rp.fetchone()
|
||||||
if row is None:
|
if row is None:
|
||||||
if self._next_rp():
|
if self._next_rp():
|
||||||
@ -48,5 +48,7 @@ class ResultIter(object):
|
|||||||
raise StopIteration
|
raise StopIteration
|
||||||
return dict(zip(self.keys, row))
|
return dict(zip(self.keys, row))
|
||||||
|
|
||||||
|
next = __next__
|
||||||
|
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
return self
|
return self
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user