Try to make convert row work on sqla 1.3 and 1.4.

This commit is contained in:
Friedrich Lindenberg 2021-12-16 10:21:40 +01:00
parent 8c91b6feaa
commit 602d52f416

View File

@ -6,10 +6,9 @@ from sqlalchemy.exc import ResourceClosedError
QUERY_STEP = 1000
row_type = OrderedDict
class DatasetException(Exception):
pass
try:
# SQLAlchemy > 1.4.0, new row model.
from sqlalchemy.engine import Row # noqa
def convert_row(row_type, row):
if row is None:
@ -17,6 +16,19 @@ def convert_row(row_type, row):
return row_type(row._mapping.items())
except ImportError:
# SQLAlchemy < 1.4.0, no _mapping.
def convert_row(row_type, row):
if row is None:
return None
return row_type(row.items())
class DatasetException(Exception):
pass
def iter_result_proxy(rp, step=None):
"""Iterate over the ResultProxy."""
while True: