Skip to content

Instantly share code, notes, and snippets.

@graffic
Created April 26, 2019 07:34
Show Gist options
  • Save graffic/4873112c02914f5f8717296bcbf8d86a to your computer and use it in GitHub Desktop.
Save graffic/4873112c02914f5f8717296bcbf8d86a to your computer and use it in GitHub Desktop.
Django tests show SQL queries
from django.test import TestCase
class TestSomething(TestCase):
def setUp(self):
from django.conf import settings
settings.DEBUG=True
def test_something(self):
pass
def tearDown(self):
from django.db import connection
for query in connection.queries:
print(f"✅ {query['sql']}\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment