Use the SqlToSlackApiFileOperator to post query result as a file to Slack channel(s) through Slack API.

Using the Operator


Operator supports two methods for upload files, which controlled by slack_method_version, by default it use Slack SDK method upload_files however this might impact a performance and cause random API errors. It is recommended to switch to Slack SDK method upload_files_v2 by set v2 to slack_method_version, however this action required to add additional scope to your application:

  • files:write - for write files.

  • files:read - for read files (not required if you use Slack SDK >= 3.23.0).

  • channels:read - get list of public channels, for convert Channel Name to Channel ID.

  • groups:read - get list of private channels, for convert Channel Name to Channel ID

  • mpim:read - additional permission for API method conversations.list

  • im:read - additional permission for API method conversations.list

This operator will execute a custom query in the provided SQL connection and publish a file to Slack channel(s).

An example usage of the SqlToSlackApiFileOperator is as follows:


    sql="SELECT 6 as multiplier, 9 as multiplicand, 42 as answer",
    slack_initial_comment="Awesome compressed multiline JSON.",
    df_kwargs={"orient": "records", "lines": True},

Was this entry helpful?