pylib: helper function to renew the DB connection

mysql for some reason sometimes present a different view of the
database even if there is not transaction pending (aka everything
has been commited).

When in this situation a renewConnection will fix this problem