From doc how can I see the raw SQL queries Django is running?
I can get sql executed by:
from django.db import connection
connection.queries
But it's only available while Debug == True
How to print sql as Debug == False
?
Thanks
Update
I want something like this:
from django.db import connection
from django.db import reset_queries
reset_queries() # Clears the query.
with transaction.atomic():
r = Amodel.objects.create(
...
)
Bmodel.objects.filter(id__in=handle_ids_).update(status=4)
# Prints the sql executed in this transaction block.
logger.info("[sql_execute]: {}".format(connection.queries))