PgDB: add possibility to provide query parameters on doSelect()

This commit is contained in:
Benjamin Renard 2021-07-12 12:16:42 +02:00
parent 198d6021b4
commit 8dbb067996

21
PgDB.py
View file

@ -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