We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 5e8cc59 + e6a1fcb commit 05088bcCopy full SHA for 05088bc
debug_toolbar/management/commands/debugsqlshell.py
@@ -1,5 +1,6 @@
1
import os
2
from optparse import make_option
3
+from datetime import datetime
4
5
from django.db.backends import util
6
from django.core.management.commands.shell import Command
@@ -8,11 +9,15 @@
8
9
10
class PrintQueryWrapper(util.CursorDebugWrapper):
11
def execute(self, sql, params=()):
12
+ starttime = datetime.now()
13
try:
14
return self.cursor.execute(sql, params)
15
finally:
16
raw_sql = self.db.ops.last_executed_query(self.cursor, sql, params)
17
+ execution_time = datetime.now() - starttime
18
print sqlparse.format(raw_sql, reindent=True)
19
print
20
+ print 'Execution time: %fs' % execution_time.total_seconds()
21
+ print
22
23
util.CursorDebugWrapper = PrintQueryWrapper
0 commit comments