salt.states.mysql_query

Execution of MySQL queries

New in version 2014.7.0.

depends:
  • MySQLdb Python module
configuration:

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

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)