Fix for issue #25

Remains to be tested in the test lab, but this should at least recover
from closed db connections with both py-mysqldb and psycopg2