Monday, April 11, 2011

Best Practice for Raw SQL

My application includes some existing tables from another, non-Django
application. One of them does not have an atomic primary key, and I'm
not in a position to change that. Therefore, I'm using one raw SQL to
access the data.
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.

In an earlier application with a similar situation, I took the results
from the query and built a dictionary of objects. Clumsy, hard-coded,
and likely slow, but it did give me what I needed.

I've looked around the web, but haven't found any practices to follow,
so I hope members of the group can offer some help.

Have you tackled this dilemma in the past? Or maybe read where someone
else has discussed a possible solution? (I'll also take wild guesses).
Please leave a comment below.

Thanks!!

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

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate