airflow.providers.slack.transfers.sql_to_slack

Module Contents

Classes

SqlToSlackApiFileOperator

Executes an SQL statement in a given SQL connection and sends the results to Slack API as file.

SqlToSlackOperator

Executes an SQL statement in a given SQL connection and sends the results to Slack Incoming Webhook.

class airflow.providers.slack.transfers.sql_to_slack.SqlToSlackApiFileOperator(*, sql, sql_conn_id, sql_hook_params=None, parameters=None, slack_conn_id=SlackHook.default_conn_name, slack_filename, slack_channels=None, slack_initial_comment=None, slack_title=None, slack_base_url=None, slack_method_version='v1', df_kwargs=None, action_on_empty_df='send', **kwargs)[source]

Bases: airflow.providers.slack.transfers.base_sql_to_slack.BaseSqlToSlackOperator

Executes an SQL statement in a given SQL connection and sends the results to Slack API as file.

See also

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

Parameters
  • sql (str) – The SQL query to be executed

  • sql_conn_id (str) – reference to a specific DB-API Connection.

  • slack_conn_id (str) – Slack API Connection.

  • slack_filename (str) – Filename for display in slack. Should contain supported extension which referenced to SUPPORTED_FILE_FORMATS. It is also possible to set compression in extension: filename.csv.gzip, filename.json.zip, etc.

  • sql_hook_params (dict | None) – Extra config params to be passed to the underlying hook. Should match the desired hook constructor params.

  • parameters (list | tuple | Mapping[str, Any] | None) – The parameters to pass to the SQL query.

  • slack_channels (str | Sequence[str] | None) – Comma-separated list of channel names or IDs where the file will be shared. If omitting this parameter, then file will send to workspace.

  • slack_initial_comment (str | None) – The message text introducing the file in specified slack_channels.

  • slack_title (str | None) – Title of file.

  • slack_base_url (str | None) – A string representing the Slack API base URL. Optional

  • slack_method_version (typing_extensions.Literal[v1, v2]) – The version of the Slack SDK Client method to be used, either “v1” or “v2”.

  • df_kwargs (dict | None) – Keyword arguments forwarded to pandas.DataFrame.to_{format}() method.

  • action_on_empty_df (typing_extensions.Literal[send, skip, error]) –

    Specifying how to handle an empty sql output df. Possible values:

    • send: (default) send the slack with an empty file.

    • skip: skip sending the slack message. Task state set to “skipped”.

    • error: raise an error to fail the task. Task state set to “failed”.

template_fields: Sequence[str] = ('sql', 'slack_channels', 'slack_filename', 'slack_initial_comment', 'slack_title')[source]
template_ext: Sequence[str] = ('.sql', '.jinja', '.j2')[source]
template_fields_renderers[source]
SUPPORTED_FILE_FORMATS: Sequence[str] = ('csv', 'json', 'html')[source]
slack_hook()[source]

Slack API Hook.

execute(context)[source]

Derive when creating an operator.

Context is the same dictionary used as when rendering jinja templates.

Refer to get_template_context for more context.

class airflow.providers.slack.transfers.sql_to_slack.SqlToSlackOperator(*args, **kwargs)[source]

Bases: airflow.providers.slack.transfers.sql_to_slack_webhook.SqlToSlackWebhookOperator

Executes an SQL statement in a given SQL connection and sends the results to Slack Incoming Webhook.

Deprecated, use airflow.providers.slack.transfers.sql_to_slack_webhook.SqlToSlackWebhookOperator

Was this entry helpful?