

Ask YC: Anyone have a good implementation for multiple database support in Django? - shafqat

We're looking at Django, and while we love most of what we see in the 1.0 release, I'm a bit worried about the lack of multiple database support.<p>Has anyone here implemented this (basic usages for mysql master/slave(s) replication)? I'm not too concerned with sharding at the moment?<p>If you have done this, care to share ideas? Thoughts? Code?<p>Thanks all!
======
mdasen
Don't do this in Django. Just don't.

This should be done with a database proxy server. With MySQL, you can use
MySQL Proxy and PostgreSQL has pgpool-II.

Yes, you could hack the Django code to solve your problem. Why do that when
there is a very simple and tested product that already does that
transparently? For me, supporting multiple databases in a web framework is
akin to writing an HTTP server into your web framework. Maybe you should do it
for testing purposes, but not for production.

~~~
ii
There are reasons why mysql_replicated backend was created and used
successfully in production instead of MySQL Proxy.

For example, MySQL Proxy knows nothing about transactions.

------
dmpayton
Just after DjangoCon there was a long discussion on django-dev about
implementing multi-db support in the upcoming releases:

[http://groups.google.com/group/django-
developers/browse_thre...](http://groups.google.com/group/django-
developers/browse_thread/thread/9f0353fe0682b73)

Also, according to JKM, Django 1.0 _does_ suport multi-db, it's just
undocumented and at a lower level:

[http://www.reddit.com/r/programming/comments/6zbos/django_10...](http://www.reddit.com/r/programming/comments/6zbos/django_10_release_candidate_now_available/c05a68v)

HTH.

~~~
dmpayton
Followup (better late than never, right?) --

A few days after my post, Eric Florenzano put up a how-to for multi-db support
in Django:

[http://www.eflorenzano.com/blog/post/easy-multi-database-
sup...](http://www.eflorenzano.com/blog/post/easy-multi-database-support-
django/)

------
yourabi
At DjangoCon I heard Pownce was doing that internally, you might want to ping
them.

~~~
shafqat
Good idea. I'll send Leah an email...

------
ii
MySQL master/slave replication is implemented:

<http://softwaremaniacs.org/soft/mysql_replicated/en/>

I'm not sure whether authors are here or not.

------
iamelgringo
Unless my memory fails me, in the "What Ponies do you want in Django?"
session, this one came up quite a bit. Adrian and Jacob said that this was one
of their top priorities, and suggested that it might make it into Django 1.1.

You could probably get a better response on the Django-users or Django-dev
mailing lists.

------
madels
do you agree that good database design means good database implementation?

------
utx00
bmk

~~~
utx00
i'm just trying to bookmark this article so that it appears under my comments.
if anyone can suggest a better way (and bookmarking on the browser is not good
enough, as i move around computers all day)

~~~
yan
If you upvote this article, it will show up under "saved" in your member
profile page.

~~~
utx00
ah thanks. is there a limit?

