def ensure_grant(self, privileges, on, username, login_from="%", with_grant_option=False):

        if self.has_grant(privileges, on, username, login_from, with_grant_option):
            return False

        grant_option_string = ""
        if with_grant_option:
            grant_option_string = " WITH GRANT OPTION"

        if not '.' in on:
            on = '%s.*' % on

        grant_string = "GRANT %s ON %s TO '%s'@'%s'%s" % (privileges, on, username, login_from, grant_option_string)
        self.__execute_non_query(grant_string)
        self.log("User %s@%s did not have grant '%s' on %s. Privileges granted!" % (username, login_from, privileges, on))

        return True
Ensures that the given user has the given privileges on the specified location.
dataset/ETHPy150Open python-provy/provy/provy/more/centos/database/mysql.py/MySQLRole.ensure_grant