New in version 2014.7.0.
MySQLdb Python module
See salt.modules.mysql
for setup instructions.
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, **connection_args)¶Execute an arbitrary query on the specified database
Used only as an ID
The name of the database to execute the query on
The query to execute
grain: output in a grain other: the file to store results None: output to the result comment (default)
grain to store the output (need output=grain)
the specified grain will be treated as a dictionary, the result of this state will be stored under the specified key.
The file or grain will be overwritten if it already exists (default)
salt.states.mysql_query.
run_file
(name, database, query_file=None, output=None, grain=None, key=None, overwrite=True, saltenv=None, **connection_args)¶Execute an arbitrary query on the specified database
New in version 2017.7.0.
Used only as an ID
The name of the database to execute the query_file on
The file of mysql commands to run
grain: output in a grain other: the file to store results None: output to the result comment (default)
grain to store the output (need output=grain)
the specified grain will be treated as a dictionary, the result of this state will be stored under the specified key.
The file or grain will be overwritten if it already exists (default)
The saltenv to pull the query_file from