Allow users to see in the console all SQL queries made by the Django ORM.
Project description
django-sql-debug
Allow users to see in the console all SQL queries made by the Django ORM.
Examples
Debugging a single query
from django_sql_debug import debug_sql
with @debug_sql():
SomeModel.objects.get(id=5) # will be captured
SomeModel.objects.get(id=5) # will not be captured
Debugging a single test
from django_sql_debug import debug_sql
class MyTest(TestCase):
@debug_sql()
def test_will_show_executed_sql(self):
SomeModel.objects.get(id=5)
def test_will_not_show_executed_sql(self):
SomeModel.objects.create(name='test')
Debugging you entire Test class
You can wrap your entire TestCase class to output the SQL executed.
from django_sql_debug import DebugSQLTestCaseMixin
class MyTest(DebugSQLTestCaseMixin, TestCase):
def test_will_show_executed_sql(self):
SomeModel.objects.get(id=5)
def test_will_also_show_executed_sql(self):
SomeModel.objects.create(name='test')
Debugging the entire application
Add django_sql_debug
to the INSTALLED_APPS
and MIDDLEWARES
.
INSTALLED_APPS = [
'django_sql_debug',
...
]
MIDDLEWARE = [
'django_sql_debug.DebugSQLMiddleware',
...
]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for django_sql_debug-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6a984c65d7230ef4ca86c9bf2053a85a506637d60f05ba1344c4ce8f17d265b2 |
|
MD5 | d9f6f2d38c371d224fadcdd7f1532ff5 |
|
BLAKE2b-256 | 8d85e4f1b4d798b5ee09d5848c4c83ac7e043b4dc4c0832bcbd71c63465342a5 |