Re: Re: Reusing connections quixote 2

Arturo FM <[email protected]> Wed, 8 Nov 2006 16:33:39 +0000 (GMT)
Newsgroups gmane.comp.web.quixote.user
Message-ID <[email protected]>
>AFAIK the only way to check a connection is to do a query and see if
>it raises an exception.
I have thinked a possible solution. I readed this info:

http://www.sqlalchemy.org/docs/dbengine.myt#dbengine_options
http://www.sqlalchemy.org/docs/pooling.myt#pooling

I think its possible to write a class for get a connection from the pool and execute a query. The pool will do the 'hard work'. With 
     'pool_recycle=3600' the pool recycle connections after one hour, so MySQL connections always 'lives'.  But,  what happens if the pool recycle a connection while an user execute a query?
I haven't found info about it.

On the other hand, I would like to use only the needed classes of SQLAlchemy for  pooling, but I think it is not possible because 'create_engine' returns a SQLAlchemy's connection object.

In my view I have three options:
a) Use one connection for each process and write a cron job for restart my application each 6 hours. 
b) Use a connection pool (SQLAlchemy) with 'pool_recycle'. 
c) Write a class with a method where I ask to pool for a connection database, execute a query and return the connection to pool. Each query must use this method..

What do you think about?
 
----------------------------
Arturo Fernandez (artufm at yahoo dot es)


	
	
		
______________________________________________ 
LLama Gratis a cualquier PC del Mundo. 
Llamadas a fijos y móviles desde 1 céntimo por minuto. 
http://es.voice.yahoo.com