'Make sure a connection is in autocommit mode.'

def set_autocommit(self):

    if hasattr(self.connection.connection, 'autocommit'):
        if callable(self.connection.connection.autocommit):
            self.connection.connection.autocommit(True)
        else:
            self.connection.connection.autocommit = True
    elif hasattr(self.connection.connection, 'set_isolation_level'):
        self.connection.connection.set_isolation_level(0)
