I dont know how I can do that. Right now my a.py and b.py declare
their own declarative_base that get subclassed by my table
definations. The main goal here is that a is not aware of b and vice
versa and I cant pass Base to an import. So I need to combine the
metadata of multiple declarative bases together.

I was just thinking maybe I can create sqlalchemy.MetaData() and then
iterate over a.metadata['tables'] and b's and then tack on my
relationship and create_all from this. But then I guess i would have
to use mapper to connect a.Group and b.User to the new metadata that i
just generated. I dont know if this would work or much less, be an
optimal solution.

On Feb 14, 11:38 am, [email protected] wrote:
> use one decl-base for all?
>
> On Saturday 14 February 2009 18:30:14 dasacc22 wrote:
>
> > Hi,
>
> > Say I have two different files that I import that establish tables
> > via declarative_base, so
>
> > import a, b
>
> > where there exists a.Group and b.User and then I create my engine
>
> > engine = create_engine(...)
>
> > and then I ..
>
> > a.metadata.bind = engine
> > b.metadata.bind = engine
>
> > or I could call create_all(engine) or whatever. But what I want to
> > do is create a many-to-many table called group_users and set ..
>
> > a.User.groups = relation('Group', secondary=group_users,
> > backref='user')
> > b.Group.users = relation('User', secondary=group_users,
> > backref='group')
>
> > and right now i do this by creating a third metadata that i bind to
> > engine. But unfortunately its not aware of either tables from the
> > first two metadatas that ive imported.
>
> > Is there a way that I can merge all metadata's? Or make my
> > relational metadata aware of the tables in the first two?
>
> > Thanks,
> > Daniel
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" 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/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to