开发者

django SQL Console

开发者 https://www.devze.com 2023-02-25 15:03 出处:网络
I am trying to debug a piece of SQL that is coming back incorrectly. I am not sure if django or mysql is handling it wrong so I want开发者_Go百科 to run it through a django console.

I am trying to debug a piece of SQL that is coming back incorrectly. I am not sure if django or mysql is handling it wrong so I want开发者_Go百科 to run it through a django console.

Is there a way to set this up?

Thanks in advance.


manage.py dbshell or manage.py shell shell being going into the python interpreter loading your project settings, dbshell putting you in the database cli client. django.db.queries holds the queries that django creates. bigmattyh's suggestion of debug toolbar is a good one, but not interactive.


A good place to start is to install the django debug toolbar in your project. It provides an unobtrusive interface that gives you access to the SQL queries so you can hunt down what's happening at that level.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号