diff options
| author | Adrian Holovaty <adrian@holovaty.com> | 2005-07-19 19:55:31 +0000 |
|---|---|---|
| committer | Adrian Holovaty <adrian@holovaty.com> | 2005-07-19 19:55:31 +0000 |
| commit | c9f90060a5ff716630d393046bb3348dc5f50c0e (patch) | |
| tree | 72e0164217407b24071b9b4d66eea2d2436931e0 /docs/faq.txt | |
| parent | 3ad2a774a7b9224c1cd4890b9d99c6871c414372 (diff) | |
Added 'How can I see the raw SQL queries Django is running?' to the FAQ
git-svn-id: http://code.djangoproject.com/svn/django/trunk@218 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs/faq.txt')
| -rw-r--r-- | docs/faq.txt | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/docs/faq.txt b/docs/faq.txt index b7ca2169a6..f208ab771b 100644 --- a/docs/faq.txt +++ b/docs/faq.txt @@ -222,6 +222,26 @@ but we recognize that choosing a template language runs close to religion. There's nothing about Django that requires using the template language, so if you're attached to ZPT, Cheetah, or whatever, feel free to use those. +The database API +================ + +How can I see the raw SQL queries Django is running? +---------------------------------------------------- + +Make sure your Django ``DEBUG`` setting is set to ``True``. Then, just do +this:: + + >>> from django.core.db import db + >>> db.queries + [{'sql': 'SELECT polls_polls.id,polls_polls.question,polls_polls.pub_date FROM polls_polls', + 'time': '0.002'}] + +``db.queries`` is only available if ``DEBUG`` is ``True``. It's a list of +dictionaries in order of query execution. Each dictionary has the following:: + + ``sql`` -- The raw SQL statement + ``time`` -- How long the statement took to execute, in seconds. + The admin site ============== |
