I've had success using sql to define views to other databases and then linking 
an "unmanaged" model to the view.  This is with MySQL where different 
"databases" are really on the same db server.

-----Original Message-----
From: [email protected] [mailto:[email protected]] On 
Behalf Of qMax
Sent: Thursday, September 09, 2010 12:38 PM
To: Django users
Subject: Re: model across several databases

On Sep 9, 3:50 pm, Russell Keith-Magee <[email protected]>
wrote:
> On Thu, Sep 9, 2010 at 8:48 AM, qMax <[email protected]> wrote:
> > Hi.
>
> > Being quite new in django,
> > I have a task to integrate data from multiple databases.
> > And I wonder if django-1.2 multibase capabilities can help me in that.
>
> > The idea is like that:
> > class PersonModel(Model):
> >    id         = AutoKey(primary_key=True)
> >    system = ForeignKey(SystemUsers, blank=True)
> >    staff      = ForeignKey(Staff, blank=True)
> >    foo        = ForeignKey(FooPeople, blank=True)
> > Problem is that SystemUsers, Staff , FooPeople are in different
> > databases, thus i cannot use just django.db.models.ForeignKey
>
> This issue is specifically addressed in the multi-db docs:
>
> http://docs.djangoproject.com/en/1.2/topics/db/multi-db/#cross-databa...
>
> It's a known limitaiton; you *might* be able to work around it, but
> it's not an official supported behavior, so it's pretty much up to you
> to tinker.

I got the idea.
But in my use case, foreign tables are not django-managed, they are
very foreign, and database desintegrity is supposed by application
design.
As a validation, It's enough just to nullify a relation if related
object suddenly disappeared - either at the moment of model retrieval,
or when relation is referenced.

Now I just wonder, if i have to implement such stuff from scratch, or
there's some useful functionality in django internals.

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


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

Reply via email to