Hi All,

Suppose I have packageA that defines:

from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
class User(Base)
  __tablename__ = 'user'
  ...

Now, I have a packageB that defines:

from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
class Something(Base)
  ...

I want Something to have a foreign key that points at User.
How do I do that?

The tables for packageA and packageB should exist in the same database (the extraction of User into packageA is just so that all our projects that need "users" get the same schema for the 'user' and related tables and functionality for users).

I guess things could be engineered such that one MetaData instance is shared between all the bases (how would that be done though? I'd need to get the MetaData instance into each of the packages before declarative_base is called...)

Moreover, how do I get all the Base's to share a _decl_class_registry?
(I'm still hazy on why the information in _decl_class_registry can't go into MetaData, rather than having two registries...)

Any ideas gratefully received...

Chris

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

Reply via email to