From da547037b971cbe8e9052a6460df4395ed937c4c Mon Sep 17 00:00:00 2001 From: Ming Fang Date: Thu, 21 Dec 2023 15:59:11 -0500 Subject: [PATCH] make compatible with sqlalchemy v2 --- schemainspect/pg/obj.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/schemainspect/pg/obj.py b/schemainspect/pg/obj.py index bc8639a..af8acaf 100644 --- a/schemainspect/pg/obj.py +++ b/schemainspect/pg/obj.py @@ -1138,13 +1138,10 @@ def processed(q): super(PostgreSQL, self).__init__(c, include_internal) def execute(self, *args, **kwargs): - result = self.c.execute(*args, **kwargs) - - if result is None: - return self.c.fetchall() - else: - return result - + with self.c.connect() as conn: + result = conn.execute(*args, **kwargs) + return result.fetchall() + def load_all(self): self.load_schemas() self.load_all_relations()