airflow.providers.microsoft.mssql.operators.mssql

Module Contents

class airflow.providers.microsoft.mssql.operators.mssql.MsSqlOperator(*, sql: str, mssql_conn_id: str = 'mssql_default', parameters: Optional[Union[Mapping, Iterable]] = None, autocommit: bool = False, database: Optional[str] = None, **kwargs)[source]

Bases: airflow.models.BaseOperator

Executes sql code in a specific Microsoft SQL database

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.

Parameters
  • sql (str or string pointing to a template file with .sql extension. (templated)) -- the sql code to be executed

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

  • parameters (dict or iterable) -- (optional) the parameters to render the SQL query with.

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

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

template_fields = ['sql'][source]
template_ext = ['.sql'][source]
ui_color = #ededed[source]
get_hook(self)[source]

Will retrieve hook as determined by Connection.

If conn_type is 'odbc', will use OdbcHook. Otherwise, MsSqlHook will be used.

execute(self, context: dict)[source]

Was this entry helpful?