PgDB: add possibility to provide query parameters on doSelect()
This commit is contained in:
parent
198d6021b4
commit
8dbb067996
1 changed files with 12 additions and 9 deletions
21
PgDB.py
21
PgDB.py
|
@ -70,15 +70,18 @@ class PgDB(object):
|
||||||
self.con.rollback()
|
self.con.rollback()
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def doSelect(self,sql):
|
def doSelect(self,sql,params):
|
||||||
cursor = self.con.cursor()
|
cursor = self.con.cursor()
|
||||||
try:
|
try:
|
||||||
cursor.execute(sql)
|
if params is None:
|
||||||
results = cursor.fetchall()
|
cursor.execute(sql)
|
||||||
return results
|
else:
|
||||||
except Exception:
|
cursor.execute(sql,params)
|
||||||
logging.error(u'Error during SQL request "%s"', sql.decode('utf-8', 'ignore'), exc_info=1)
|
results = cursor.fetchall()
|
||||||
return False
|
return results
|
||||||
|
except Exception:
|
||||||
|
logging.error(u'Error during SQL request "%s"', sql.decode('utf-8', 'ignore'), exc_info=1)
|
||||||
|
return False
|
||||||
|
|
||||||
#
|
#
|
||||||
# SQL helpers
|
# SQL helpers
|
||||||
|
|
Loading…
Reference in a new issue