Add the pessimistic disconnect handler

I got this from
http://docs.sqlalchemy.org/en/latest/core/pooling.html#disconnect-handling-pessimistic
as a way to handle MySql going away in exchange for an extra request per
new session. Hopefully it will help me to avoid problems with
my long-running process