Open sant527 opened 5 years ago
@sant527 Wrapping the sqlparse.format(...) in print() does the job. This is because sqlparse.format returns a raw formatted string.
print(sqlparse.format(
db.connection.queries[-1]['sql'],
reindent=True,
keyword_case='upper'
))
In Django i want to see the sql in jupyter notebook in the way same way shown using ipython
Eg:
The sql is show in a very well formated way which is very easy to understand.
Now i want to try that in jupyter notebook
From here i followed the answer: https://stackoverflow.com/a/54632855
It says to install django_print_sql which i did then try to run
django_print_sql: it says 0 queries and shows no sql output
Also i installed sqlparser and tried the solution mentioned
The above sql does not look well formated at all.
So
django_print_sql
andsqlparser
are not giving a colorful formatted sql which is given by thepython manage.py shell_plus --ipython --print-sql
So how to get the sql in jupyter notebook for Django projects.