首页 > 解决方案 > 如何使用环境变量在 Airflow 中定义 https 连接

问题描述

在 Airflow 中,http(和其他)连接可以定义为环境变量。但是,很难https为这些连接使用模式。

这样的连接可能是:

export AIRFLOW_CONN_MY_HTTP_CONN=http://example.com

但是,无法定义安全连接:

export AIRFLOW_CONN_MY_HTTP_CONN=https://example.com

因为 Airflow 剥离了方案 ( https) 并且在最终的连接对象中,url 得到http了方案。

事实证明,可以https通过这样定义连接来使用:

export AIRFLOW_CONN_MY_HTTP_CONN=https://example.com/https

第二个在气流代码https中调用schema(如 DSN 中的 eg postgresql://user:passw@host/schema)。然后schema将其用作scheme连接对象中最终 url 的构造。

我想知道这是设计使然,还是只是schemeschema.

标签: airflow

解决方案


您应该使用Connections,然后您可以指定架构。


推荐阅读