aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Adams2010-01-14 07:35:10 -0800
committerRob Hudson2010-01-14 07:35:10 -0800
commitfba93b813f90430545d5acaa25ef218f792360ab (patch)
tree090d151c9066628c2d1caee649343f804f29e810
parenta3497040db69e0f5d2f6e02f11e3ed4ed378b2cb (diff)
downloaddjango-debug-toolbar-fba93b813f90430545d5acaa25ef218f792360ab.tar.bz2
Views.py tweaked to use friendlier "EXPLAIN QUERY PLAN" with sqlite3
Signed-off-by: Rob Hudson <rob@cogit8.org>
-rw-r--r--debug_toolbar/views.py10
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()