From ef510a36ee943e34ee14e24d9730f52f610c8758 Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Fri, 19 Nov 2021 11:52:50 +0100 Subject: [PATCH] OracleDB: add debug of SQL query in doSQL & doSelect methods --- mylib/oracle.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/mylib/oracle.py b/mylib/oracle.py index 3664a65..edeac24 100644 --- a/mylib/oracle.py +++ b/mylib/oracle.py @@ -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)