Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

django SQL Console

Tags:

django

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 to run it through a django console.

Is there a way to set this up?

Thanks in advance.

like image 667
chantheman Avatar asked Apr 13 '11 23:04

chantheman


2 Answers

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.

like image 186
Mike Ramirez Avatar answered Sep 20 '22 07:09

Mike Ramirez


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.

like image 41
Matt Howell Avatar answered Sep 20 '22 07:09

Matt Howell