On Nov 27, 2012, at 5:53 AM, Daniel Rentsch wrote:

> Hi all,
> 
> We are trying to implement a locking mechanism which relies on the 
> incoming/used connections returned/used by SQLAlchemy. The problem we ran 
> into is that SQLAlchemy uses a new database connection after calling 
> expire_all() if we use the autocommit=True functionality. We expected that 
> only one connection is used in one session.
> 
> More precisely: 
> 
> IF  you use *autocommit=True*
>    IF  you call call *expire_all* 
>    AND AFTER THIS generate a query with more than one affected tables via 
> *filter_by*
>    THEN SQLAlchemy will use multiple connections


A Session using autocommit=True will pull a new connection from the connection 
pool for each individual execute operation, or each flush().   If you want only 
one connection used per session, you either need to stick with the recommended 
autocommit=False (the connection will be per-transaction, actually), or bind 
the Session to a single connection directly (sess = 
Session(bind=some_connection)).



-- 
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