I believe I have fixed my problem. Instead of binding/rebinding a given engine instance to the Session, I bind to the metadata object. This solves the problem instead. I found that there are numerous references to being able to rebind metadata but not sessions.
On Sep 23, 9:03 am, Andrew <[EMAIL PROTECTED]> wrote: > Hi: > > I have been having problems in attempting to rebind a given Session > object/class to a different engine instance. It seems that it can only > be bound once. Subsequent sql statements post to the original binding. > I am using sqlalchemy 0.4.6 with elixir. Here is an example: > > __session__ = scoped_session(sessionmaker(...)) > > Session.configure(bind=engine1) > > # do sql ops here on engine1 via elixir > > __session__.configure(bind=engine2) > > # do sql ops here against engine2 via elixir > # sql ops here get written to database that engine1 is pointing to. > > The 2 engines I am referring to have identical schemas in different > databases. In fact there may be multiple databases (with the same > schema) in which I need to set the database context before performing > sql operations. I thought the __session__.configure(bind=) would do > the trick but it doesn't seem to be working. Can anyone provide some > insight into how I can use sqlalchemy to write to multiple databases > with the same schema? As shown this app is multithreaded (zope). I > have received some advice to create a new session instance per schema > (eg: sess=Session()) however elixir only refers to a single session > object/class (__session__) which makes things difficult. Do I need to > dump elixir and just use sqlalchemy to get this functionality? > > Thanks! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---