On Jul 10, 12:37 pm, Ben Kreeger <benjaminkree...@gmail.com> wrote:
> How do I go about accessing that data from P2's database? Do I need to
> create a model in P1 and bind it to a certain table in P2's database?
> If that's the case, how do I specify access credentials for that
> database? Is that in settings.py?

If the two projects live in completely separate databases, then there
is no easy way to do that (yet -- there's a GSoC project being
actively worked on by Alex Gaynor to provide multi-database support in
Django)

In a similar situation, where both projects had a database on a common
mysql server, I managed to do this with a one-line change to the
Django mysql backend, which allowed me to specify a table in the
model's Meta class as "database.table" -- this only works because
MySQL allows you to access tables in one database from a connection to
another, as long as your credentials are valid for both.

Another (mysql-only, unfortunately) solution is to run mysqlproxy in
front of your P2 database, and have it direct requests for P1 tables
to the P1 database server. You would have to be careful to avoid any
sort of queries that tried to join the tables from the two databases
together, though -- avoiding foreign keys from P1 models to P2 models
should be enough.

Ian
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to