SqlToSlackOperator

Use the sql_to_slack to post messages to predefined Slack channel.

Using the Operator

This operator will execute a custom query in the provided SQL connection and publish a Slack message that can be formatted and contain the resulting dataset (e.g. ASCII formatted dataframe).

An example usage of the SqlToSlackOperator is as follows:

tests/system/providers/slack/example_sql_to_slack.py[source]

SqlToSlackOperator(
    task_id="presto_to_slack",
    sql_conn_id=SQL_CONN_ID,
    sql=f"SELECT col FROM {SQL_TABLE}",
    slack_channel="my_channel",
    slack_conn_id='slack_default',
    slack_message="message: {{ ds }}, {{ results_df }}",
)

Was this entry helpful?