Monday, April 30, 2012

Re: executing raw sql

On Mon, 30 Apr 2012 12:46:34 -0600, Larry Martell
<larry.martell@gmail.com> declaimed the following in
gmane.comp.python.django.user:

> I'm trying to execute some raw sql. I found some code that did this:
>
> from django.db import connection
> cursor = connection.cursor()
> cursor.execute(sql)
> data = cursor.fetchall()
>
> But the cursor.execute(sql) is blowing up with:
>
> 'Cursor' object has no attribute '_last_executed'
>
> What is the best or proper way for me to execute my raw sql?

What's the actual code (you list a sample you found somewhere, which
not complete -- for example, just what does "sql" contain?).

What database engine are you using?

What is the traceback of the error?

etc... too much information is missing to make a guess... (Well,
I'll make an hypothesis based upon the so-called error message: you have
an engine which saves previous SQL statements, and if "sql" in None will
attempt to re-execute the previously saved SQL -- but you don't have a
previously saved SQL statement.)
--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/

--
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