diff options
| author | Rob Hudson | 2011-09-26 21:15:06 -0700 | 
|---|---|---|
| committer | Rob Hudson | 2011-09-26 21:15:06 -0700 | 
| commit | 05088bcb457aa495467103f16f788be639146d34 (patch) | |
| tree | 2f98b208bee98eba75e0bf6b62287d9fcb91a733 | |
| parent | 5e8cc5961c74ca57b0eb5d6ac387ee81604443ab (diff) | |
| parent | e6a1fcb0a21161ecb4f3393a2cfd3cc591c83543 (diff) | |
| download | django-debug-toolbar-05088bcb457aa495467103f16f788be639146d34.tar.bz2 | |
Merge pull request #164 from gwrtheyrn/master
Display execution time with query in debugsqlshell. Thanks gwrtheyrn.
| -rw-r--r-- | debug_toolbar/management/commands/debugsqlshell.py | 5 | 
1 files changed, 5 insertions, 0 deletions
| diff --git a/debug_toolbar/management/commands/debugsqlshell.py b/debug_toolbar/management/commands/debugsqlshell.py index 71723fa..8878d25 100644 --- a/debug_toolbar/management/commands/debugsqlshell.py +++ b/debug_toolbar/management/commands/debugsqlshell.py @@ -1,5 +1,6 @@  import os  from optparse import make_option +from datetime import datetime  from django.db.backends import util  from django.core.management.commands.shell import Command @@ -8,11 +9,15 @@ from debug_toolbar.utils import sqlparse  class PrintQueryWrapper(util.CursorDebugWrapper):      def execute(self, sql, params=()): +        starttime = datetime.now()          try:              return self.cursor.execute(sql, params)          finally:              raw_sql = self.db.ops.last_executed_query(self.cursor, sql, params) +            execution_time = datetime.now() - starttime              print sqlparse.format(raw_sql, reindent=True)              print +            print 'Execution time: %fs' % execution_time.total_seconds() +            print  util.CursorDebugWrapper = PrintQueryWrapper | 
