On Fri, Nov 18, 2011 at 5:18 PM, Tom Evans <tevans...@googlemail.com> wrote:

> On Fri, Nov 18, 2011 at 4:20 PM, Kayode Odeyemi <drey...@gmail.com> wrote:
> > Just for the sake of learning. How am I the one creating the queries? I
> only
> > created a model to be saved by calling save() on it. The rest is left to
> > Django to handle as I can see in the traceback. Though I never saw the
> sql
> > (which is what I've been looking for) .
> >
> > py-mysqldb also doesn't create the query. It does some magic of
> importing a
> > MySQL C library and then doing something like db.query() on the
> Connection
> > subclass, with _mysql.connection as it's parent. But the exact query()
> > method was never found. I just couldn't trace it.
>
>
> I just re-read the stack trace; you're right. I misread your original
> code snippet as "This is the code I'm running, and this is the stack
> trace it generates", in which case DDT would work, or simply looking
> in django.db.connection.queries would show you 'almost' the SQL it
> sends.
>
> Eg, if you can reproduce it in a shell:
> from django.db import connection
> connection.queries[-1]['sql'] # get the last query executed
>

Cool! This is really very helpful.

>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Odeyemi 'Kayode O.
http://www.sinati.com. t: @charyorde

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to