Code

Ticket #5415: 5415.diff

File 5415.diff, 1.2 KB (added by czhang, 7 years ago)

I tried to come up this simple patch, but I have no idea how to test this properly.

Line 
1Index: django/db/backends/util.py
2===================================================================
3--- django/db/backends/util.py  (revision 6354)
4+++ django/db/backends/util.py  (working copy)
5@@ -1,6 +1,8 @@
6 import datetime
7 import md5
8 from time import time
9+from django.core import signals
10+from django.dispatch import dispatcher
11 from django.utils.encoding import smart_unicode, force_unicode
12 
13 try:
14@@ -15,6 +17,7 @@
15 
16     def execute(self, sql, params=()):
17         start = time()
18+        dispatcher.send(signal=signals.dbapi_sql_execute, sender=self, sql=sql, params=params)
19         try:
20             return self.cursor.execute(sql, params)
21         finally:
22@@ -26,6 +29,7 @@
23 
24     def executemany(self, sql, param_list):
25         start = time()
26+        dispatcher.send(signal=signals.dbapi_sql_execute, sender=self, sql=sql, params=params_list)
27         try:
28             return self.cursor.executemany(sql, param_list)
29         finally:
30Index: django/core/signals.py
31===================================================================
32--- django/core/signals.py      (revision 6354)
33+++ django/core/signals.py      (working copy)
34@@ -1,3 +1,4 @@
35 request_started = object()
36 request_finished = object()
37 got_request_exception = object()
38+dbapi_sql_execute = object()