From 8dbb067996a42593e552a0fc52fd8128943afbd4 Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Mon, 12 Jul 2021 12:16:42 +0200 Subject: [PATCH] PgDB: add possibility to provide query parameters on doSelect() --- PgDB.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/PgDB.py b/PgDB.py index 5720d67..7136fe9 100644 --- a/PgDB.py +++ b/PgDB.py @@ -70,15 +70,18 @@ class PgDB(object): self.con.rollback() return False - def doSelect(self,sql): - cursor = self.con.cursor() - try: - cursor.execute(sql) - results = cursor.fetchall() - return results - except Exception: - logging.error(u'Error during SQL request "%s"', sql.decode('utf-8', 'ignore'), exc_info=1) - return False + def doSelect(self,sql,params): + cursor = self.con.cursor() + try: + if params is None: + cursor.execute(sql) + else: + cursor.execute(sql,params) + results = cursor.fetchall() + return results + except Exception: + logging.error(u'Error during SQL request "%s"', sql.decode('utf-8', 'ignore'), exc_info=1) + return False # # SQL helpers