Simon Willison: Django | Multiple Databases
simonwillison.net
simonwillison.net
Is that doc-page outdated/incomplete or did it really take them 4 years and a 21kloc patch to tie a model to a database instance? I mean, I don't see anything about proper partitioning/sharding, not a glimpse of cross-db queries. Is this a joke?
SqlAlchemy has had proper multi-db support (vertical and horizontal) since around 2007. Perhaps the time would be better spent porting django to a real ORM?
http://www.sqlalchemy.org/docs/06/session.html#partitioning-...
Obviously the solution is to specify a mapping somewhere, but there's no need to hold up the feature while waiting for a design for that particular bikeshed.
Instead, the plan is to release an initial version with low level primitives: the ability to configure multiple databases and specify which database should be used for a given query. This gives us a chance to see what kind of patterns are most widely used and figure out the correct way to support those at a higher level of the API.
In my opinion, the SQLAlchemy example demonstrates why handling sharding automatically is a distinctly non-trivial problem: http://www.sqlalchemy.org/trac/browser/sqlalchemy/trunk/exam... - it's not clear to me that that's a better solution than just manually picking the database to execute a query on at the point of execution.
Sorry, but "seeing what patterns are most widely used" is a lame excuse. You could just look at what real world sites do today (and did 4 years ago) - or simply jump right to implementing the only anonymous sharding model that can possibly work (see how mongodb does it).
I'm not meaning to bash django as a whole here, but I had a true WTF-moment looking at that page. It seems the home-grown ORM is becoming a ball on a chain if something like that takes this long...
Anyways, at least it's progress in the right direction, looking forward to real partitioning support, hopefully in earlier than another 4 years.
Moreover, it did not take four years to develop multi-db support. This was a GSoC 2009 project that was merged in 2009.
Django uses svn for the core repository, but the majority of the actual work takes place in git or mercurial. Django has committers using both.