thatsanicehatyouh...@mac.com wrote:
This is a bit tricky to explain. Imagine I have one database, and I create a 
project (1) to work with that database (connections, table class definitions, 
etc.). That is standalone (to me). I have another completely separate database 
(2) on another host where I do the same thing. Using replication I then create 
a read-only copy of database 1 in database 2, and join some of the tables. 
Project 2 needs to generate the classes, but use SA's Base class that is 
dynamically generated. Since it's dynamic, I have to create it at run time... 
but now I can't pass that to the definition of project 1's classes. It's that 
communication that I'm struggling with.

Difficult to know what you're after so two guesses:

- if you have multiple python packages that need to share a declarative Base, either have one "master" package that defines the Base and import from that or, if you prefer completely normalised dependencies, move the Base definition out its own package (where stuff shared between your packages such as mixins, session setup functions, etc can live) and have both packages import from there.

- if you have different python packages on two different projects running on two different machines or in different processes, then just have each create their own Base. The Base is merely a collection of references to the SA mapped classes, much like the MetaData object, so it's fine to have different ones in different processes, even if they're both accessing the same tables in the same databases...

cheers,

Chris

--
Simplistix - Content Management, Batch Processing & Python Consulting
           - http://www.simplistix.co.uk

--
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