Monday, April 30, 2012

Re: executing raw sql

On Mon, Apr 30, 2012 at 6:26 PM, Dennis Lee Bieber
<wlfraed@ix.netcom.com> wrote:
> On Mon, 30 Apr 2012 15:29:08 -0600, Larry Martell
> <larry.martell@gmail.com> declaimed the following in
> gmane.comp.python.django.user:
>
>>
>> But in django I am doing this:
>>
>> from django.db import connection
>> cursor = connection.cursor()
>> cursor.execute(sql)
>>
>> and it's getting the error, so that would mean that the sql isn't
>> getting executed for some reason. I'll have to investigate that
>> avenue.
>
>        You still haven't show us what "sql" contains... Given your three
> statements I'd expect to get an error message since "sql" itself is
> undefined.

I figured out the problem. I had %s in my sql, and they was getting
treated as a format specifier. When I built the sql I did put in '%%',
but I had to put in 4 '%%%%' for it to work.

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment