5 ms·
Ask YC: Anyone have a good implementation for multiple database support in Django?
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.
Has anyone here implemented this (basic usages for mysql master/slave(s) replication)? I'm not too concerned with sharding at the moment?
If you have done this, care to share ideas? Thoughts? Code?
Thanks all!
- mdasen 18y agoDon'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 18y agoThere 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.
- ii 18y agoMySQL master/slave replication is implemented: http://softwaremaniacs.org/soft/mysql_replicated/en/ http://softwaremaniacs.org/soft/mysql_replicated/en/ I'm not sure whether authors are here or not.
- dmpayton 18y agoJust 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_thread/thread/9f0353fe0682b73 http://groups.google.com/group/django-developers/browse_thre... 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_release_candidate_now_available/c05a68v http://www.reddit.com/r/programming/comments/6zbos/django_10... HTH.
- shafqat 18y agoThanks for the links. Sounds promising!
- dmpayton 18y agoFollowup (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-support-django/ http://www.eflorenzano.com/blog/post/easy-multi-database-sup...
- yourabi 18y agoAt DjangoCon I heard Pownce was doing that internally, you might want to ping them.
- shafqat 18y agoGood idea. I'll send Leah an email...
- utx00 18y agobmk
- utx00 18y agoi'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)
- unexpected 18y agoum, delicious?
- utx00 18y agothanks. i stopped using it about a year ago because it was getting really slow. maybe i should have another looksie.
- yan 18y agoIf you upvote this article, it will show up under "saved" in your member profile page.
- utx00 18y agoah thanks. is there a limit?
- lacker 18y agoHow about saying something marginally intelligent. ;-)
- iamelgringo 18y agoUnless 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 18y agodo you agree that good database design means good database implementation?