I want to monitor query time in my system(built with Django models
).
Finally I found django.db.connection.queries
.
It shows all queries and time taking for it.
Using this, I want to print the list of which I have done queries at regular interval and then I want to clear the list I printed after printing.
It seems to have methods for a list object(pop, remove
and so on).
But Even though I call pop()
, It doesn't have any effect, still showing the same length.
How can I clear the list..?
Or Is there any other methods for my intention?
p.s I also found Django-debug-toolbar
but it seems only for view part.
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. connection. queries includes all SQL statements – INSERTs, UPDATES, SELECTs, etc.
Django gives you two ways of performing raw SQL queries: you can use Manager. raw() to perform raw queries and return model instances, or you can avoid the model layer entirely and execute custom SQL directly. Explore the ORM before using raw SQL!
You can call reset_queries()
from the django.db module.
from django.db import reset_queries
reset_queries()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With