aboutsummaryrefslogtreecommitdiffstats
path: root/debug_toolbar/management/commands/debugsqlshell.py
diff options
context:
space:
mode:
Diffstat (limited to 'debug_toolbar/management/commands/debugsqlshell.py')
-rw-r--r--debug_toolbar/management/commands/debugsqlshell.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/debug_toolbar/management/commands/debugsqlshell.py b/debug_toolbar/management/commands/debugsqlshell.py
index e94e4e2..c5718b8 100644
--- a/debug_toolbar/management/commands/debugsqlshell.py
+++ b/debug_toolbar/management/commands/debugsqlshell.py
@@ -1,24 +1,23 @@
from __future__ import print_function, unicode_literals
-from datetime import datetime
+from time import time
from django.db.backends import util
import sqlparse
-from debug_toolbar.utils import ms_from_timedelta
-
class PrintQueryWrapper(util.CursorDebugWrapper):
def execute(self, sql, params=()):
- starttime = datetime.now()
+ start_time = time()
try:
return self.cursor.execute(sql, params)
finally:
raw_sql = self.db.ops.last_executed_query(self.cursor, sql, params)
- execution_time = ms_from_timedelta(datetime.now() - starttime)
+ end_time = time()
+ duration = (end_time - start_time) * 1000
formatted_sql = sqlparse.format(raw_sql, reindent=True)
- print('%s [%.2fms]' % (formatted_sql, execution_time))
+ print('%s [%.2fms]' % (formatted_sql, duration))
util.CursorDebugWrapper = PrintQueryWrapper