[Zope-dev] Re: zope.sqlalchemy

Michael Bayer mike_mp at zzzcomputing.com
Wed May 7 09:33:05 EDT 2008


On May 7, 2008, at 7:08 AM, Martijn Faassen wrote:

> Hi there (especially Christian),
>
> I think we can work with explicits saves. In many cases the user  
> won't have to worry about it anyway as the container object will do  
> it for them (besides making the relation), or this 'query container'  
> we spoke of will do it for them (but just the 'save' bit).
>
> One point is that the scoped session approach itself doesn't work  
> very well for using multiple databases in the same app. We could  
> consider passing the session along in the containers during object  
> graph wakling (or traversal) so an app can easily traverse into  
> multiple databases. I'm not sure whether we can make the ORM do this  
> for us though; does it initialize the mapping with a session?
>

SQLAlchemy's Session does support multiple engine binds itself, which  
most easily can be associated with particular mapped classes (i.e.  
vertical partitioning),  so that a single session (or a  
scoped_session) can read and write data to the appropriate tables  
transparently (although things like joins across multiple databases  
will raise errors).   Theres a horizontally-partitioning version of  
Session as well which obviously has a lot more caveats.

Using multiple sessions, one per DB is a valid approach as well.     
I'm not sure if Grok has other things going on when mulitple DBs are  
in use but SA's multi-bind capability is something to be aware of.


More information about the Zope-Dev mailing list