Skip to content

Commit d0c424c

Browse files
committed
Display execution time after query
1 parent e08ec8c commit d0c424c

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

debug_toolbar/management/commands/debugsqlshell.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os
22
from optparse import make_option
3+
from datetime import datetime
34

45
from django.core.management.base import NoArgsCommand
56
from django.db.backends import util
@@ -8,12 +9,16 @@
89

910
class PrintQueryWrapper(util.CursorDebugWrapper):
1011
def execute(self, sql, params=()):
12+
starttime = datetime.today()
1113
try:
1214
return self.cursor.execute(sql, params)
1315
finally:
1416
raw_sql = self.db.ops.last_executed_query(self.cursor, sql, params)
17+
execution_time = datetime.today() - starttime
1518
print sqlparse.format(raw_sql, reindent=True)
1619
print
20+
print 'Execution time: %fs' % execution_time.total_seconds()
21+
print
1722

1823
util.CursorDebugWrapper = PrintQueryWrapper
1924

0 commit comments

Comments
 (0)