airflow.providers.mysql.operators.mysql

Module Contents

Classes

MySqlOperator

Executes sql code in a specific MySQL database

class airflow.providers.mysql.operators.mysql.MySqlOperator(*, sql, mysql_conn_id='mysql_default', parameters=None, autocommit=False, database=None, **kwargs)[source]

Bases: airflow.models.BaseOperator

Executes sql code in a specific MySQL database

See also

For more information on how to use this operator, take a look at the guide: MySqlOperator

Parameters
  • sql (Union[str, List[str]]) -- the sql code to be executed. Can receive a str representing a sql statement, a list of str (sql statements), or reference to a template file. Template reference are recognized by str ending in '.sql' (templated)

  • mysql_conn_id (str) -- Reference to mysql connection id.

  • parameters (Optional[Union[Mapping, Iterable]]) -- (optional) the parameters to render the SQL query with. Template reference are recognized by str ending in '.json' (templated)

  • autocommit (bool) -- if True, each command is automatically committed. (default value: False)

  • database (Optional[str]) -- name of database which overwrite defined one in connection

template_fields :Sequence[str] = ['sql', 'parameters'][source]
template_fields_renderers[source]
template_ext :Sequence[str] = ['.sql', '.json'][source]
ui_color = #ededed[source]
prepare_template(self)[source]

Parse template file for attribute parameters.

execute(self, context)[source]

This is the main method to derive when creating an operator. Context is the same dictionary used as when rendering jinja templates.

Refer to get_template_context for more context.

Was this entry helpful?