diff options
| author | Danilo Bargen | 2011-05-19 19:15:37 +0200 |
|---|---|---|
| committer | Danilo Bargen | 2011-05-19 19:15:37 +0200 |
| commit | d0c424c0c6a26ad9ea190319ad5d1e5872d63f6c (patch) | |
| tree | 0fd6f47c79260428b7d5b17c0344ccfc4ea453b7 /debug_toolbar/management/commands/debugsqlshell.py | |
| parent | e08ec8c6ac0b4d9471c33460bd5c615293c0da59 (diff) | |
| download | django-debug-toolbar-d0c424c0c6a26ad9ea190319ad5d1e5872d63f6c.tar.bz2 | |
Display execution time after query
Diffstat (limited to 'debug_toolbar/management/commands/debugsqlshell.py')
| -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 eaeafd4..e323401 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.core.management.base import NoArgsCommand from django.db.backends import util @@ -8,12 +9,16 @@ from debug_toolbar.utils import sqlparse class PrintQueryWrapper(util.CursorDebugWrapper): def execute(self, sql, params=()): + starttime = datetime.today() try: return self.cursor.execute(sql, params) finally: raw_sql = self.db.ops.last_executed_query(self.cursor, sql, params) + execution_time = datetime.today() - starttime print sqlparse.format(raw_sql, reindent=True) print + print 'Execution time: %fs' % execution_time.total_seconds() + print util.CursorDebugWrapper = PrintQueryWrapper |
