Should we have a database independent SQL like query language in Django?
-
**Note :** - I know we have `Django ORM` already that keeps things database independent and converts to the database specific `SQL` queries. - Once things starts getting complicated it is preferred to write `raw SQL` queries for better efficiency. - When you write `raw sql` queries your code gets trapped with the database you are using. - I also understand its important to use the full power of your database that can-not be achieved with the `django orm` alone. My Question : - Until I use any database specific feature, why should one be trapped with the database. - For instance : > We have a query with multiple joins and we decided to write a raw sql > query. Now, that makes my website `postgres` specific. Even when I > have not used any postgres specific feature. I feel there should be some `fake sql` language which can translate to any database's sql query. Even Django's ORM can be built over it. So, that if you go out of ORM but not database specific - you can still remain database independent. I asked the same question to `Jacob Kaplan Moss` (In person) : - He advised me to stay with the database that I like and endure its whole power, to which I agree. But my point was not that we should be `database independent`. - My point is we should be database independent until we use a database specific feature. Please explain, why should be there a `fake sql` layer over the actual sql ?
-
Answer:
There is absolutely no benefit in being able to have your specific web application work on multiple databases (other than maybe sqlite for speed of tests). You will never *ever* switch between engines in production, and there is no reason you should. Pick one, stick with it. Also SQL is a standard. Most things work just fine in the ORM, and if you're already writing custom queries when you can't even figure out what database to use, then you're likely doing something wrong.
David Cramer at Quora Visit the source
Other answers
I agree with David Cramer 100%. SQL has been around for decades, and problems or not, it's an established standards with volumes and volumes of implementation details written around it. Okay, let's move onto something David Cramer didn't cover. Creating a new "META" SQL language means getting everyone to adopt it. Let's say you manage that and it becomes a new standard. Then you risk a whole new problem... What will likely happen minor (individuals) and major players (database makers) will begin to implement their own versions of your "META" SQL. The community will fragment and you'll be back to where we are with SQL, but with another layer of complexity on top of it. It's happened with SQL, JavaScript, HTML specifications (IE comes to mind here) and other specifications. My advice: Stick with what we have for SQL and the concept of ORMs. If you need to drop down into raw SQL, write your queries that way. If you have to switch databases in development, just grin and bear the extra work.
Daniel Roy Greenfeld
Hm.. I would if I can. What I meant to say was that we are already covering all the subtle edge cases with django's orm. What I feel is that this should have been done by the `fake sql` [covering the edge cases] and django orm built on top of it. Tell me if I make sense. Thanks for your time sir !
Yugal Jindle
Related Q & A:
- How to match a drawn Chinese character to a database of stroke animations?Best solution by Signal Processing
- How to add primary key from multiple table as a foreign key in a table in sql server 2008?Best solution by stackoverflow.com
- How to present large dataset from a SQL Server query?Best solution by stackoverflow.com
- How good is a career as a Database Administrator?Best solution by Yahoo! Answers
- What is a good independent news site?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.