Module Contents



Executes sql code in a specific Microsoft SQL database

class*, sql, mssql_conn_id='mssql_default', parameters=None, autocommit=False, database=None, **kwargs)[source]

Bases: airflow.models.BaseOperator

Executes sql code in a specific Microsoft SQL database

See also

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

This operator may use one of two hooks, depending on the conn_type of the connection.

If conn_type is 'odbc', then OdbcHook is used. Otherwise, MsSqlHook is used.

  • sql (str) -- the sql code to be executed (templated)

  • mssql_conn_id (str) -- reference to a specific mssql database

  • parameters (Optional[Union[Mapping, Iterable]]) -- (optional) the parameters to render the SQL query with.

  • 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'][source]
template_ext :Sequence[str] = ['.sql'][source]
ui_color = #ededed[source]

Will retrieve hook as determined by get_hook() if one is defined, and MsSqlHook otherwise.

For example, if the connection conn_type is 'odbc', OdbcHook will be used.

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?