#NEWLINE# def ensure_user( self , username , identified_by , login_from = '%' ) : #NEWLINE# #INDENT# "\n        Ensure the given user is created in the database and can login from the specified location.\n\n        :param username: Name of the user to be created.\n        :type username: :class:`str`\n        :param identified_by: Password that the user will use to login to mysql server.\n        :type identified_by: :class:`str`\n        :param login_from: Locations that this user can login from. Defaults to '%' (anywhere).\n        :type login_from: :class:`str`\n        :return: Whether the user had to be created or not.\n        :rtype: :class:`bool`\n\n        Example:\n        ::\n\n            class MySampleRole(Role):\n                def provision(self):\n                    with self.using(MySQLRole) as role:\n                        role.ensure_user('someuser', 'somepass', 'localhost')\n        " #NEWLINE# if ( not self . user_exists ( username , login_from ) ) : #NEWLINE# #INDENT# self . __execute_non_query ( ( "CREATE USER '%s'@'%s' IDENTIFIED BY '%s';" % ( username , login_from , identified_by ) ) ) #NEWLINE# self . log ( ( 'User %s not found with login access for %s. User created!' % ( username , login_from ) ) ) #NEWLINE# return True #NEWLINE# #UNINDENT# return False