views:

109

answers:

1

I have a set of Django models that are used in two databases (i.e. syncdb was run against two databases from the same app). Both databases are for production services (one database contains on-demand "sandbox" build information and the other contains nightly build information).

The problem is that I want to have one Django app that displays information from both databases. Is that possible in Django? The solution that I've been using so far is to run the app against the nightly build database and use raw SQL to access the sandbox build database, but that's not DRY and just feels wrong.

Thanks.

+5  A: 

Django currently does not support more than one database. However, support is planned for version 1.2 and a lot of work has been done already (see ticket #1142 and this thread on django-developers).

If you are interested in getting a head start on this (and helping to test it out) there are directions in the above thread on how to check out it out via git or svn.

Wogan
See also: http://code.djangoproject.com/wiki/MultipleDatabaseSupport
T. Stone
Thanks. I found this link (linked from the django-developers thread) very useful: http://code.djangoproject.com/browser/django/branches/soc2009/multidb/docs/topics/db/multi-db.txt
Zach Hirsch
Note that this multi-database support has now been merged into Django trunk, so it is available for use (if you're willing to to run trunk).
Carl Meyer