Try to fix #365.

This commit is contained in:
Friedrich Lindenberg 2021-04-22 18:51:20 +02:00
parent 45794d349f
commit c13b79fc59

View File

@ -19,7 +19,6 @@ def convert_row(row_type, row):
def iter_result_proxy(rp, step=None):
"""Iterate over the ResultProxy."""
try:
while True:
if step is None:
chunk = rp.fetchall()
@ -29,19 +28,21 @@ def iter_result_proxy(rp, step=None):
break
for row in chunk:
yield row
except ResourceClosedError:
return
class ResultIter(object):
""" SQLAlchemy ResultProxies are not iterable to get a
list of dictionaries. This is to wrap them. """
"""SQLAlchemy ResultProxies are not iterable to get a
list of dictionaries. This is to wrap them."""
def __init__(self, result_proxy, row_type=row_type, step=None):
self.row_type = row_type
self.result_proxy = result_proxy
try:
self.keys = list(result_proxy.keys())
self._iter = iter_result_proxy(result_proxy, step=step)
except ResourceClosedError:
self.keys = []
self._iter = iter([])
def __next__(self):
try: