|
|
@@ -36,7 +36,9 @@ class CustomDb(pypyodbc.Connection):
|
|
|
""" yield rows as NamedTupleRow """
|
|
|
cursor = self.execute(sql)
|
|
|
row = cursor.fetchone()
|
|
|
- rowmodel = namedtuple("Row", [column[0] for column in cursor.description])
|
|
|
+ fieldnames = [(column[0].lower() if column[0].isidentifier() else "field_{}".format(i)) for i, column in enumerate(cursor.description)]
|
|
|
+
|
|
|
+ rowmodel = namedtuple("Row", fieldnames)
|
|
|
while row:
|
|
|
yield rowmodel(*row)
|
|
|
row = cursor.fetchone()
|