How can I see the raw SQL queries Django is running?
446 —————————————————- 447 448 Make sure your Django “DEBUG“ setting is set to “True“. Then, just do 449 this:: 450 451 >>> from django.db import connection 452 >>> connection.queries 453 [{‘sql’: ‘SELECT polls_polls.id,polls_polls.question,polls_polls.pub_date FROM polls_polls’, 454 ‘time’: ‘0.002’}] 455 456 “connection.queries“ is only available if “DEBUG“ is “True“. It’s a list 457 of dictionaries in order of query execution. Each dictionary has the following:: 458 459 “sql“ — The raw SQL statement 460 “time“ — How long the statement took to execute, in seconds. 461 462 “connection.queries“ includes all SQL statements — INSERTs, UPDATES, 463 SELECTs, etc. Each time your app hits the database, the query will be recorded.