I was using PostgreSQL at first, but then I found information about reading data across databases only with MySQL, so I'm using MySQL for the time being.
Now, I don't have a database set for P1 yet because it's just displaying reStructuredText files; if I were to set up that site to access P2's database (in P1's settings.py file), would I be able to (eek) do raw SQL to get the data to display the way I want? Or would there be an easier way to do that WITHOUT raw SQL, and WITHOUT duplicating that model declared on P2? Ben On Jul 10, 3:58 pm, Ian Clelland <clell...@gmail.com> wrote: > 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 -~----------~----~----~----~------~----~------~--~---