Skip to content

Commit c1f7b3a

Browse files
committed
Made usable connections with alias not in db.connections
1 parent e806603 commit c1f7b3a

File tree

1 file changed

+9
-1
lines changed
  • debug_toolbar/utils/tracking

1 file changed

+9
-1
lines changed

debug_toolbar/utils/tracking/db.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,14 @@ def execute(self, sql, params=()):
8888
try:
8989
return self.cursor.execute(sql, params)
9090
finally:
91+
# FIXME: Sometimes connections which are not in the connections
92+
# dict are used (for example in test database destroying).
93+
# The code below (at least get_transaction_id(alias) needs to have
94+
# the connection in the connections dict. It would be good to
95+
# not have this requirement at all, but for now lets just skip
96+
# these connections.
97+
if self.db.alias not in connections:
98+
return
9199
stop = datetime.now()
92100
duration = ms_from_timedelta(stop - start)
93101
enable_stacktraces = getattr(settings,
@@ -119,7 +127,7 @@ def execute(self, sql, params=()):
119127
del cur_frame
120128

121129
alias = getattr(self.db, 'alias', 'default')
122-
conn = connections[alias].connection
130+
conn = self.db.connection
123131
# HACK: avoid imports
124132
if conn:
125133
engine = conn.__class__.__module__.split('.', 1)[0]

0 commit comments

Comments
 (0)