PgDB: add debug of SQL query in doSQL & doSelect methods
This commit is contained in:
parent
ef510a36ee
commit
9c35ead28e
1 changed files with 18 additions and 2 deletions
|
@ -133,6 +133,14 @@ class PgDB:
|
|||
|
||||
cursor = self._conn.cursor()
|
||||
try:
|
||||
log.debug(
|
||||
'Run SQL query "%s" %s',
|
||||
sql,
|
||||
"with params = %s" % ', '.join([
|
||||
"%s = %s" % (key, value)
|
||||
for key, value in params.items()
|
||||
]) if params else "without params"
|
||||
)
|
||||
if params is None:
|
||||
cursor.execute(sql)
|
||||
else:
|
||||
|
@ -141,7 +149,7 @@ class PgDB:
|
|||
return True
|
||||
except Exception:
|
||||
log.error(
|
||||
'Error during SQL request "%s" %s',
|
||||
'Error during SQL query "%s" %s',
|
||||
sql,
|
||||
"with params = %s" % ', '.join([
|
||||
"%s = %s" % (key, value)
|
||||
|
@ -164,12 +172,20 @@ class PgDB:
|
|||
"""
|
||||
cursor = self._conn.cursor()
|
||||
try:
|
||||
log.debug(
|
||||
'Run SQL SELECT query "%s" %s',
|
||||
sql,
|
||||
"with params = %s" % ', '.join([
|
||||
"%s = %s" % (key, value)
|
||||
for key, value in params.items()
|
||||
]) if params else "without params"
|
||||
)
|
||||
cursor.execute(sql, params)
|
||||
results = cursor.fetchall()
|
||||
return results
|
||||
except Exception:
|
||||
log.error(
|
||||
'Error during SQL request "%s" %s',
|
||||
'Error during SQL query "%s" %s',
|
||||
sql,
|
||||
"with params = %s" % ', '.join([
|
||||
"%s = %s" % (key, value)
|
||||
|
|
Loading…
Reference in a new issue