[sqlalchemy] Re: Reconnect while loosing Mysql connection

2012-06-12 Thread Pavel Skvazh
Too obvious or too complicated?

On Monday, June 4, 2012 7:10:14 PM UTC+4, Pavel Skvazh wrote:

 Hi, everyone!

 Due to an obviously lacking skills of an admin, the connection with Mysql 
 sever is really spotty.

 And I keep getting OperationalError 'Can't connect to MySQL server' error 
 every once in a while.
 What's the best practice approach to handle this kind of errors.
 Logical way would be to try to reconnect N times every N seconds and if it 
 fails - throw this error.
 Doing it manually doesn't seem appropriate and natural. Code won't be 
 pretty either.
 Connection pool looks like the way to go. i.e. try to get another 
 connection if this one dies for some reason. It doesn't look like it's the 
 way it is.

 Any help would be highly appreciated.


-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sqlalchemy/-/QKPokWMzPbkJ.
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.



Re: [sqlalchemy] Re: Reconnect while loosing Mysql connection

2012-06-12 Thread Michael Bayer
turn off pooling is the quickest, use NullPool.

otherwise set pool_recycle very low, or add a ping event.

Docs for all of this at:

http://docs.sqlalchemy.org/en/rel_0_7/core/pooling.html



On Jun 12, 2012, at 2:07 PM, Pavel Skvazh wrote:

 Too obvious or too complicated?
 
 On Monday, June 4, 2012 7:10:14 PM UTC+4, Pavel Skvazh wrote:
 Hi, everyone!
 
 Due to an obviously lacking skills of an admin, the connection with Mysql 
 sever is really spotty.
 
 And I keep getting OperationalError 'Can't connect to MySQL server' error 
 every once in a while.
 What's the best practice approach to handle this kind of errors.
 Logical way would be to try to reconnect N times every N seconds and if it 
 fails - throw this error.
 Doing it manually doesn't seem appropriate and natural. Code won't be pretty 
 either.
 Connection pool looks like the way to go. i.e. try to get another connection 
 if this one dies for some reason. It doesn't look like it's the way it is.
 
 Any help would be highly appreciated.
 
 -- 
 You received this message because you are subscribed to the Google Groups 
 sqlalchemy group.
 To view this discussion on the web visit 
 https://groups.google.com/d/msg/sqlalchemy/-/QKPokWMzPbkJ.
 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.