/usr/lib/python2.7/dist-packages/debug_toolbar/management/commands/debugsqlshell.py is in python-django-debug-toolbar 1:1.0.1-0+nmu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | from __future__ import absolute_import, print_function, unicode_literals
from time import time
# 'debugsqlshell' is the same as the 'shell'.
from django.core.management.commands.shell import Command # noqa
from django.db.backends import util
import sqlparse
class PrintQueryWrapper(util.CursorDebugWrapper):
def execute(self, sql, params=()):
start_time = time()
try:
return self.cursor.execute(sql, params)
finally:
raw_sql = self.db.ops.last_executed_query(self.cursor, sql, params)
end_time = time()
duration = (end_time - start_time) * 1000
formatted_sql = sqlparse.format(raw_sql, reindent=True)
print('%s [%.2fms]' % (formatted_sql, duration))
util.CursorDebugWrapper = PrintQueryWrapper
|