To solve this problem, you should open a new db session at the beginning of 
the web request, and close the session at the end of the request.
See the pattern here:

http://docs.sqlalchemy.org/en/latest/orm/session.html#using-thread-local-scope-with-web-applications

On Monday, October 31, 2011 5:45:56 AM UTC-7, somewhatofftheway wrote:
>
> Hi all,
>
> I'm seeing this error intermittently in my application since switching to 
> MySQL - it occurs on several different pages and I can't track down why:
>
> StatementError: Can't reconnect until invalid transaction is rolled back 
> (original cause: InvalidRequestError: Can't reconnect until invalid 
> transaction is rolled back) 'SELECT [... the same select every time, which 
> gets a user from the database]
>
> I have searched on the error and read the various discussions, for example 
> this one:
>
>
> http://groups.google.com/group/sqlalchemy/browse_thread/thread/a8031eefc4d5d0cd
>
> My understanding is that somewhere in my code I need to be ensuring that I 
> do rollback/commit/close when the operation is complete. The problem is... 
> where? Is there a way I can get a log to see the original query/point in my 
> code which triggers the error.
>
> If it is relevant, I'm using Pyramid and have recently also suffered from 
> 'MySQL has gone away errors'.
>
> Thanks,
> Ben
>
> [also described this problem on the Pyramid list, apologies to those of 
> you that subscribe to both]
>

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to