Arturo FMwrites: > >The smart reconnect modules also have connection pooling. It will > >leave unused connections open and hand them back to the next routine > >that asks for one. SQLAlchemy has this and there's also a standalone > >module I'm planning to try, although I can't find the link to it now. > >SQLObject has the same feature but I'm not sure if you can use it > >alone (without SQLObject's OO features). > OK! I will find this module of SQLAlchemy. I think that I could write a class with methods for check if the connection is "alive". If the exception is thrown then try to reconnect. > > On 11/7/06, Arturo FM wrote: > > >The smart reconnect modules also have connection pooling. It will > > >leave unused connections open and hand them back to the next routine > > >that asks for one. SQLAlchemy has this and there's also a standalone > > >module I'm planning to try, although I can't find the link to it now. > > >SQLObject has the same feature but I'm not sure if you can use it > > >alone (without SQLObject's OO features). > > > OK! I will find this module of SQLAlchemy. I think that I could write a class with methods for check if the connection is "alive". If the exception is thrown then try to reconnect. > > Mike Orr writes: > The point is, you don't have to! This is jumping into the middle of > the manual, but with SQLAlchemy you can set a lifetime on connections, > after which they will be closed and reopened. You can set this to an > hour or two and forget about it. See the pool_recycle=3600 argument. > > http://www.sqlalchemy.org/docs/dbengine.myt#dbengine_options > > I didn't find definitive confirmation that it will transparently > reopen a connection if a query fails, but you can look in the source > to see. (It would be an exception catching.) If it doesn't, the main > thing to remember is to restart the application whenever you restart > the database server. If you don't need a connection pool and are using a lower level database module than sqlalchemy, perhaps you could explicitly check for an existing connection and reconnect if necessary. That wouldn't interfere with scgi's long running process. -larry