diff options
| author | Chris Adams | 2010-01-14 07:35:10 -0800 | 
|---|---|---|
| committer | Rob Hudson | 2010-01-14 07:35:10 -0800 | 
| commit | fba93b813f90430545d5acaa25ef218f792360ab (patch) | |
| tree | 090d151c9066628c2d1caee649343f804f29e810 /debug_toolbar | |
| parent | a3497040db69e0f5d2f6e02f11e3ed4ed378b2cb (diff) | |
| download | django-debug-toolbar-fba93b813f90430545d5acaa25ef218f792360ab.tar.bz2 | |
Views.py tweaked to use friendlier "EXPLAIN QUERY PLAN" with sqlite3
Signed-off-by: Rob Hudson <rob@cogit8.org>
Diffstat (limited to 'debug_toolbar')
| -rw-r--r-- | debug_toolbar/views.py | 10 | 
1 files changed, 9 insertions, 1 deletions
| diff --git a/debug_toolbar/views.py b/debug_toolbar/views.py index 5a412af..42d3f91 100644 --- a/debug_toolbar/views.py +++ b/debug_toolbar/views.py @@ -77,7 +77,15 @@ def sql_explain(request):      if sql.lower().strip().startswith('select'):          params = simplejson.loads(params)          cursor = connection.cursor() -        cursor.execute("EXPLAIN %s" % (sql,), params) + +        if settings.DATABASE_ENGINE == "sqlite3": +            # SQLite's EXPLAIN dumps the low-level opcodes generated for a query; +            # EXPLAIN QUERY PLAN dumps a more human-readable summary +            # See http://www.sqlite.org/lang_explain.html for details +            cursor.execute("EXPLAIN QUERY PLAN %s" % (sql,), params) +        else: +            cursor.execute("EXPLAIN %s" % (sql,), params) +          headers = [d[0] for d in cursor.description]          result = cursor.fetchall()          cursor.close() | 
