Is it possible to show SQL queries like in this command: python manage.py shell_plus --print-sql
but in Jupyter Notebook?
I tried this command python manage.py shell_plus --notebook --print-sql
but it not worked.
Is it possible to show SQL queries like in this command: python manage.py shell_plus --print-sql
but in Jupyter Notebook?
I tried this command python manage.py shell_plus --notebook --print-sql
but it not worked.
It's probably a bug in Django Extensions that you don't see SQL queries. A few versions ago, someone asked here how to disable SQL printing in Jupyter.
As a workaround, you could use django_print_sql:
You may even find that having control over which queries to print is preferable to printing all.
But I mostly just print the last query retroactively:
If you want to pretty-print the query with sqlparse, it starts getting complicated enough for a utility function: