OracleDB: add debug of SQL query in doSQL & doSelect methods

This commit is contained in:
Benjamin Renard 2021-11-19 11:52:50 +01:00
parent 366260e92a
commit ef510a36ee

View file

@ -112,6 +112,14 @@ class OracleDB:
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 isinstance(params, dict):
cursor.execute(sql, **params)
else:
@ -120,7 +128,7 @@ class OracleDB:
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)
@ -143,6 +151,14 @@ class OracleDB:
"""
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"
)
if isinstance(params, dict):
cursor.execute(sql, **params)
else:
@ -152,7 +168,7 @@ class OracleDB:
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)