From ce3be02cce8e133a7b68e6ebafb7b7a55a13e5f9 Mon Sep 17 00:00:00 2001 From: WangWeigao Date: Thu, 16 Dec 2021 16:40:18 +0800 Subject: [PATCH] Compatible with SQLAlchemy 1.4.* Compatible with SQLAlchemy 1.4.* --- records.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/records.py b/records.py index 1fd6a93..9193860 100644 --- a/records.py +++ b/records.py @@ -360,7 +360,10 @@ class Connection(object): cursor = self._conn.execute(text(query), **params) # TODO: PARAMS GO HERE # Row-by-row Record generator. - row_gen = (Record(cursor.keys(), row) for row in cursor) + row_gen = iter(Record([], [])) + + if cursor.returns_rows: + row_gen = (Record(cursor.keys(), row) for row in cursor) # Convert psycopg2 results to RecordCollection. results = RecordCollection(row_gen)