1 | Add SQL_DEBUG option that shows SQL queries
|
---|
2 |
|
---|
3 | Index: D:/web/projects/django-newforms/django/db/backends/util.py
|
---|
4 | ===================================================================
|
---|
5 | --- D:/web/projects/django-newforms/django/db/backends/util.py (revision 5753)
|
---|
6 | +++ D:/web/projects/django-newforms/django/db/backends/util.py (working copy)
|
---|
7 | @@ -19,6 +19,15 @@
|
---|
8 | return self.cursor.execute(sql, params)
|
---|
9 | finally:
|
---|
10 | stop = time()
|
---|
11 | + from django.conf import settings
|
---|
12 | + # If params was a list, convert it to a tuple, because string
|
---|
13 | + # formatting with '%' only works with tuples or dicts.
|
---|
14 | + if not isinstance(params, (tuple, dict)):
|
---|
15 | + params = tuple(params)
|
---|
16 | + if getattr(settings, 'SQL_DEBUG', False):
|
---|
17 | + if not isinstance(params, (tuple, dict)):
|
---|
18 | + params = tuple(params)
|
---|
19 | + print '>', sql % params
|
---|
20 | self.db.queries.append({
|
---|
21 | 'sql': smart_unicode(sql) % convert_args(params),
|
---|
22 | 'time': "%.3f" % (stop - start),
|
---|