In my case I had to read some legacy data from a different schema on the
same MySQL server and it was easy (but perhaps not elegant) to just
establish a separate connection using MySQLdb module.

-----Original Message-----
From: django-users@googlegroups.com
[mailto:django-users@googlegroups.com] On Behalf Of Jacob Kaplan-Moss
Sent: Monday, April 11, 2011 11:51 AM
To: django-users
Subject: Re: Best Practice for Raw SQL

On Mon, Apr 11, 2011 at 7:53 AM, Dan Gentry <d...@gentryville.net> wrote:
> Where I run into trouble is that the query returns data in columns,
> but not objects. That means that I can't reference an object attribute
> using dot notation in my templates or views. Instead, I have to
> include each attribute that will be needed as a query column. This
> will limit what I or someone else can do in templates later without a
> mod to the query.

You're looking for the `raw()` method: http://django.me/raw. It takes
a raw SQL query and yields models for you.

Jacob

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


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