From e3d8a3128557ee8a6a88f6fad1628d0278f7b3f0 Mon Sep 17 00:00:00 2001 From: Dustin Thomas Date: Sun, 14 Jan 2024 13:53:34 -0600 Subject: [PATCH] get the query to return results, or an empty list if any error occurs --- database.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/database.py b/database.py index f68e7c0..4ee403f 100644 --- a/database.py +++ b/database.py @@ -24,7 +24,13 @@ class DBConnector: self.conn.close() def _query(self, sql): - self.cur.execute(sql) + try: + self.cur.execute(sql) + result = self.cur.fetchall() + except psycopg2.DatabaseError as e: + result = [] + return result + def read(self, **kwargs): """Read rows from a database that match the specified filters.