On 6/7/06, Michael Bayer <[EMAIL PROTECTED]> wrote: > On Jun 7, 2006, at 6:57 PM, Mike Orr wrote: > > Is there a way to have the unbound metadata in the global variable, > > and then copy it to a bound metadata in the constructor? Then I could > > have self._meta instead of self._engine. I see how you can copy a > > table to another metadata but not how you can clone the whole > > metadata. Or is there a better way to do this? > > > > yes, you should probably deal with the MetaData object as your > "contextual" object rather than the Engine, if you want to be able to > switch it around. you really only need to have one DynamicMetaData > object for the whole thing, theres not much need to switch around and > all....but if you want a Table to bind itself to another MetaData > object you can use the tometadata() method on Table.
Thanks for the tips. I'm not sure what you mean here. Should I just keep on reconnecting at the beginning of each method? I'm tempted to just give each instance its own metadata and tables. It seems like it's more convenient to code, self._chemicals.insert()... Maybe my application is just unusual. BTW, does SQLAlchemy know to discard the connection and get a new one if it gets a "MySQL server has gone away" error? I saw that SQLObject2 does. I've got a MySQLdb multiprocess web application (Quixote) with long-running connections, and the server unilaterally closes the connection if the client process has been idle for so many hours. Tried raising the time limit in the MySQL config file but that didn't work, so I'm just restarting the web application three times a day. Unfortunately the assumption that connections don't die and can be set once in a module global is buried deep in the application. May rewrite it for SQLAlchemy the next time it's due for a revision. -- Mike Orr <[EMAIL PROTECTED]> _______________________________________________ Sqlalchemy-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

