Friday, June 29, 2012

Re: advantages and disadvantages of Raw sql queries in django

I firmly believe in using the ORM for everything until i am forced to use handwritten SQL.

The main reason is transparency of intentions when the source is examined by a non-DBA.

I want my code to be maintainable by other people and provably correct. I suppose you can unit-test code with embedded SQL but it adds an extra layer of complexity.

I could also argue against custom SQL because it contains business logic and i prefer to keep that all in one place, ie., in models in python code.

So the bottom line for me is to avoid it where possible.  Once everything is profiled and the last remaining bottlenecks are significant and cannot be removed unless I use custom SQL, that's when I'll do it.

Haven't gotten there yet.

-----Original message-----
From: vijay shanker <>
Django users <>
Sat, 30 Jun 2012, 14:35:54 AEST
advantages and disadvantages of Raw sql queries in django

i want to know pros and cons associated with running raw sql queries
over django's ORM .
googled it out but couldn find many useful links.

You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to
To unsubscribe from this group, send email to
For more options, visit this group at

No comments:

Post a Comment