When you create a new Python process, you must create a new engine with 
create_engine() specifically in that process, and use that for all operations.  
 DBAPI connections are not portable over process boundaries.

As far as the number of connections, the number of connections can be managed 
on the SQLAlchemy side only in terms of each engine - in a parallel process 
situation, there are many engines so the usual "pool_size" attributes don't 
have much significance.

It's typical that there is one connection per process.  So controlling the 
number of connections in this case is a matter of controlling how many parallel 
processes you create.   There should always be an upper bound on how many 
processes are created in any parallel processing application.

It's also a good idea to configure the database server to allow a max number of 
connections, though you'll want to tune your application such that it never 
hits that limit.


On Jan 31, 2011, at 6:52 AM, Eduardo wrote:

> Dear all,
> My application create parallel processes that access and query a
> database. My problem is that I can not use engine or connection object
> in any of these processes because they can not be pickled (requirement
> for the input arguments for functions that trigger processes). Is
> there any way to use the URL string to identify existing
> connection(s). In this case I could use the url to obtain existing
> connection and to bind a session created in each process to it. Does
> the reducing the number of connections necessarily results in faster
> query and storage of the data in a database? Is there any other option
> to keep number of connection optimal for an arbitrary number of
> processes?
> I have seen that there is a way to create an instance of pool class
> with the url string - I would like to know if I create this instances
> in each of my processes, is a new pool going to be created each time
> Pool class has been instantiated?
> Thank you
> 
> -- 
> 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 
> sqlalchemy+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/sqlalchemy?hl=en.
> 

-- 
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 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to