Try to make convert row work on sqla 1.3 and 1.4.
This commit is contained in:
parent
8c91b6feaa
commit
602d52f416
@ -6,17 +6,29 @@ from sqlalchemy.exc import ResourceClosedError
|
|||||||
QUERY_STEP = 1000
|
QUERY_STEP = 1000
|
||||||
row_type = OrderedDict
|
row_type = OrderedDict
|
||||||
|
|
||||||
|
try:
|
||||||
|
# SQLAlchemy > 1.4.0, new row model.
|
||||||
|
from sqlalchemy.engine import Row # noqa
|
||||||
|
|
||||||
|
def convert_row(row_type, row):
|
||||||
|
if row is None:
|
||||||
|
return None
|
||||||
|
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):
|
class DatasetException(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def convert_row(row_type, row):
|
|
||||||
if row is None:
|
|
||||||
return None
|
|
||||||
return row_type(row._mapping.items())
|
|
||||||
|
|
||||||
|
|
||||||
def iter_result_proxy(rp, step=None):
|
def iter_result_proxy(rp, step=None):
|
||||||
"""Iterate over the ResultProxy."""
|
"""Iterate over the ResultProxy."""
|
||||||
while True:
|
while True:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user