Skip to content

Instantly share code, notes, and snippets.

@savanovich
Created September 28, 2016 09:25
Show Gist options
  • Save savanovich/763d92f960988487e440be27bfd6c003 to your computer and use it in GitHub Desktop.
Save savanovich/763d92f960988487e440be27bfd6c003 to your computer and use it in GitHub Desktop.
import sqlparse
from django.conf import settings
from django.db import connection, reset_queries
settings.DEBUG = True
reset_queries()
# do orm queries...
for q in connection.queries:
print(sqlparse.format(q['sql'], reindent=True, keyword_case='upper'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment