#13101: Documentation: Add note about multiple databases and debugging raw sql
---------------------------------+------------------------------------------
Reporter: anonymous | Owner: nobody
Status: new | Milestone:
Component: Documentation | Version: SVN
Keywords: multidb, 1.2, debug | Stage: Unreviewed
Has_patch: 0 |
---------------------------------+------------------------------------------
http://docs.djangoproject.com/en/dev/faq/models/ has a section called "How
can I see the raw SQL queries Django is running?", where it suggests:
{{{
>>> from django.db import connection
>>> connection.queries
[{'sql': 'SELECT polls_polls.id,polls_polls.question,polls_polls.pub_date
FROM polls_polls',
'time': '0.002'}]
}}}
However, in a multidb scenario, that only gets the sql from the default
connection. I found a better way is this function:
{{{
def get_sql():
from django import db
q = []
for c in db.connections.all():
q.extend(c.queries)
return q
}}}
A note should probably be made about this.
--
Ticket URL: <http://code.djangoproject.com/ticket/13101>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.