Reconnect while loosing Mysql connection

67 views
Skip to first unread message

Pavel Skvazh

unread,
Jun 4, 2012, 11:10:14 AM6/4/12
to sqlal...@googlegroups.com
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.

Pavel Skvazh

unread,
Jun 12, 2012, 2:07:07 PM6/12/12
to sqlal...@googlegroups.com
Too obvious or too complicated?

Michael Bayer

unread,
Jun 12, 2012, 2:52:05 PM6/12/12
to sqlal...@googlegroups.com
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:




--
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 sqlal...@googlegroups.com.
To unsubscribe from this group, send email to sqlalchemy+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.

Reply all
Reply to author
Forward
0 new messages