[IMP] sql_db: log SQL queries before executing them

That way queries are visible at DEBUG level while they
are executing, rather than after the fact, making
the log less confusing to watch when long-running queries
are involved.

Closes #11182
This commit is contained in:
Lionel Sausin
2016-03-08 16:43:09 +01:00
committed by Olivier Dony
parent 6a979b22c0
commit 1a58e1085e
+1 -1
View File
@@ -214,6 +214,7 @@ class Cursor(object):
if self.sql_log:
now = mdt.now()
_logger.debug("query: %s", query)
try:
params = params or None
@@ -235,7 +236,6 @@ class Cursor(object):
delay = mdt.now() - now
delay = delay.seconds * 1E6 + delay.microseconds
_logger.debug("query: %s", self._obj.query)
res_from = re_from.match(query.lower())
if res_from:
self.sql_from_log.setdefault(res_from.group(1), [0, 0])