From 3d0467d9a4394c4b994a802e6e861ff2562dbb2b Mon Sep 17 00:00:00 2001
From: Vladislav Poluhin
Date: Wed, 24 Apr 2013 11:14:34 +0800
Subject: Got rid of the circular imports
---
debug_toolbar/utils/sql.py | 15 +++++++++++++++
1 file changed, 15 insertions(+)
create mode 100644 debug_toolbar/utils/sql.py
(limited to 'debug_toolbar/utils/sql.py')
diff --git a/debug_toolbar/utils/sql.py b/debug_toolbar/utils/sql.py
new file mode 100644
index 0000000..909edf7
--- /dev/null
+++ b/debug_toolbar/utils/sql.py
@@ -0,0 +1,15 @@
+import re
+from debug_toolbar.utils import sqlparse
+from debug_toolbar.utils.sqlparse.filters import BoldKeywordFilter
+
+
+def reformat_sql(sql):
+ stack = sqlparse.engine.FilterStack()
+ stack.preprocess.append(BoldKeywordFilter()) # add our custom filter
+ stack.postprocess.append(sqlparse.filters.SerializerUnicode()) # tokens -> strings
+ return swap_fields(''.join(stack.run(sql)))
+
+
+def swap_fields(sql):
+ return re.sub('SELECT (.*?) FROM', 'SELECT ••• ' +
+ '\g<1> FROM', sql)
--
cgit v1.2.3