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() cursor = self._conn.cursor()
try: 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): if isinstance(params, dict):
cursor.execute(sql, **params) cursor.execute(sql, **params)
else: else:
@ -120,7 +128,7 @@ class OracleDB:
return True return True
except Exception: except Exception:
log.error( log.error(
'Error during SQL request "%s" %s', 'Error during SQL query "%s" %s',
sql, sql,
"with params = %s" % ', '.join([ "with params = %s" % ', '.join([
"%s = %s" % (key, value) "%s = %s" % (key, value)
@ -143,6 +151,14 @@ class OracleDB:
""" """
cursor = self._conn.cursor() cursor = self._conn.cursor()
try: 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): if isinstance(params, dict):
cursor.execute(sql, **params) cursor.execute(sql, **params)
else: else:
@ -152,7 +168,7 @@ class OracleDB:
return results return results
except Exception: except Exception:
log.error( log.error(
'Error during SQL request "%s" %s', 'Error during SQL query "%s" %s',
sql, sql,
"with params = %s" % ', '.join([ "with params = %s" % ', '.join([
"%s = %s" % (key, value) "%s = %s" % (key, value)