Proposal: --debug-sql option for management commands

69 views
Skip to first unread message

Yo-Yo Ma

unread,
Oct 16, 2015, 2:36:29 PM10/16/15
to Django developers (Contributions to Django itself)
I found an N+1 query by inspecting the code of a management command that was running every 10 minutes, and it made me think, it would be good to have an option similar to https://django-debug-toolbar.readthedocs.org/en/1.0/commands.html#debugsqlshell for management commands in general.

If there interest in this, I'll look into what it would take to factor out the functionality of debugsqlshell into a --debug-sql (or whatever name) argument that could be passed to management commands in general.

Claude Paroz

unread,
Oct 17, 2015, 4:19:35 AM10/17/15
to Django developers (Contributions to Django itself)
I like the idea. However, instead of monkey-patching the Django CursorDebugWrapper like DDT is doing now, I'd rather see a solution where we use dynamic logging configuration to output the SQL commands, if possible.

Claude

Aymeric Augustin

unread,
Oct 17, 2015, 4:37:21 AM10/17/15
to django-d...@googlegroups.com
> On 17 oct. 2015, at 10:19, Claude Paroz <cla...@2xlibre.net> wrote:
>
> I like the idea. However, instead of monkey-patching the Django CursorDebugWrapper like DDT is doing now, I'd rather see a solution where we use dynamic logging configuration to output the SQL commands, if possible.


Since the option would also be available for runserver, it would fill a gap whenever the DDT isn’t usable e.g. when using Django as an API in a SPA.

On a related note, it would also be interesting to rework the DDT to hook to the django.db.backends logger instead of monkey-patching.

--
Aymeric.

Reply all
Reply to author
Forward
0 new messages