aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--debug_toolbar/panels/sql.py4
-rw-r--r--debug_toolbar/utils/tracking/db.py12
2 files changed, 5 insertions, 11 deletions
diff --git a/debug_toolbar/panels/sql.py b/debug_toolbar/panels/sql.py
index 74729c7..4bfdd27 100644
--- a/debug_toolbar/panels/sql.py
+++ b/debug_toolbar/panels/sql.py
@@ -77,9 +77,11 @@ class SQLDebugPanel(DebugPanel):
self._transaction_ids = {}
def get_transaction_id(self, alias):
+ if alias not in connections:
+ return
conn = connections[alias].connection
if not conn:
- return None
+ return
engine = conn.__class__.__module__.split('.', 1)[0]
if engine == 'psycopg2':
diff --git a/debug_toolbar/utils/tracking/db.py b/debug_toolbar/utils/tracking/db.py
index 8a51c36..d649984 100644
--- a/debug_toolbar/utils/tracking/db.py
+++ b/debug_toolbar/utils/tracking/db.py
@@ -102,14 +102,6 @@ class NormalCursorWrapper(object):
try:
return self.cursor.execute(sql, params)
finally:
- # FIXME: Sometimes connections which are not in the connections
- # dict are used (for example in test database destroying).
- # The code below (at least get_transaction_id(alias) needs to have
- # the connection in the connections dict. It would be good to
- # not have this requirement at all, but for now lets just skip
- # these connections.
- if self.db.alias not in connections:
- return
stop = datetime.now()
duration = ms_from_timedelta(stop - start)
enable_stacktraces = getattr(settings,
@@ -149,8 +141,8 @@ class NormalCursorWrapper(object):
params = {
'engine': engine,
'alias': alias,
- 'sql': self.db.ops.last_executed_query(self.cursor, sql,
- self._quote_params(params)),
+ 'sql': self.db.ops.last_executed_query(
+ self.cursor, sql, self._quote_params(params)),
'duration': duration,
'raw_sql': sql,
'params': _params,