Django

Code

Changeset 218

Show
Ignore:
Timestamp:
07/19/05 14:55:31 (3 years ago)
Author:
adrian
Message:

Added 'How can I see the raw SQL queries Django is running?' to the FAQ

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/docs/faq.txt

    r187 r218  
    223223if you're attached to ZPT, Cheetah, or whatever, feel free to use those. 
    224224 
     225The database API 
     226================ 
     227 
     228How can I see the raw SQL queries Django is running? 
     229---------------------------------------------------- 
     230 
     231Make sure your Django ``DEBUG`` setting is set to ``True``. Then, just do 
     232this:: 
     233 
     234    >>> from django.core.db import db 
     235    >>> db.queries 
     236    [{'sql': 'SELECT polls_polls.id,polls_polls.question,polls_polls.pub_date FROM polls_polls', 
     237    'time': '0.002'}] 
     238 
     239``db.queries`` is only available if ``DEBUG`` is ``True``. It's a list of 
     240dictionaries in order of query execution. Each dictionary has the following:: 
     241 
     242    ``sql`` -- The raw SQL statement 
     243    ``time`` -- How long the statement took to execute, in seconds. 
     244 
    225245The admin site 
    226246==============