def METHOD_NAME(self, rollback=False):
    if rollback:
        try:
            self.connection.rollback()
        except Exception as error:
            logging.error("Error while rollbacking connection for recreation", error)
    try:
        self.cursor.close()
    except Exception as error:
        logging.error("Error while closing cursor for recreation", error)
    self.cursor = None
    return self.__enter__()