salt.states.mysql_query
Execution of MySQL queries
The mysql_query module is used to execute queries on MySQL databases. Its output may be stored in a file or in a grain.
query_id:
mysql_query.run
- database: my_database
- query: "SELECT * FROM table;"
- output: "/tmp/query_id.txt"
salt.states.mysql_query.run(name, database, query, output=None, grain=None, key=None, overwrite=True, check_db_exists=True, **connection_args)
-
Execute an arbitrary query on the specified database
- name
- Used only as an ID
- database
- The name of the database to execute the query on
- query
- The query to execute
- output
- grain: output in a grain other: the file to store results None: output to the result comment (default)
- grain:
- grain to store the output (need output=grain)
- key:
- the specified grain will be treated as a dictionary, the result of this state will be stored under the specified key.
- overwrite:
- The file or grain will be overwritten if it already exists (default)
- check_db_exists:
- The state run will check that the specified database exists (default=True) before running any queries
salt.states.mysql_query.run_file(name, database, query_file=None, output=None, grain=None, key=None, overwrite=True, saltenv=None, check_db_exists=True, **connection_args)
-
Execute an arbitrary query on the specified database
- name
- Used only as an ID
- database
- The name of the database to execute the query_file on
- query_file
- The file of mysql commands to run
- output
- grain: output in a grain other: the file to store results None: output to the result comment (default)
- grain:
- grain to store the output (need output=grain)
- key:
- the specified grain will be treated as a dictionary, the result of this state will be stored under the specified key.
- overwrite:
- The file or grain will be overwritten if it already exists (default)
- saltenv:
- The saltenv to pull the query_file from
- check_db_exists:
- The state run will check that the specified database exists (default=True) before running any queries