2025 年 Airflow 峰会将于 10 月 07-09 日举行。立即注册抢购早鸟票!

airflow.secrets.local_filesystem

与从本地文件检索连接和变量相关的对象。

属性

log

FILE_PARSERS

LocalFilesystemBackend

从本地文件检索 Connection 对象和 Variable。

函数

get_connection_parameter_names()

返回 airflow.models.connection.Connection 构造函数参数。

load_variables(file_path)

从文本文件加载变量。

load_connections_dict(file_path)

从文本文件加载连接。

模块内容

airflow.secrets.local_filesystem.log[source]
airflow.secrets.local_filesystem.get_connection_parameter_names()[source]

返回 airflow.models.connection.Connection 构造函数参数。

airflow.secrets.local_filesystem.FILE_PARSERS[source]
airflow.secrets.local_filesystem.load_variables(file_path)[source]

从文本文件加载变量。

支持 JSON, YAML.env 文件。

参数:

file_path (str) – 将被处理的文件的位置。

airflow.secrets.local_filesystem.load_connections_dict(file_path)[source]

从文本文件加载连接。

支持 JSON, YAML.env 文件。

返回值:

一个字典,其中键包含连接 ID,值包含连接。

返回值类型:

dict[str, Any]

airflow.secrets.local_filesystem.LocalFilesystemBackend(variables_file_path=None, connections_file_path=None)[source]

基类: airflow.secrets.base_secrets.BaseSecretsBackend, airflow.utils.log.logging_mixin.LoggingMixin

从本地文件检索 Connection 对象和 Variable。

支持 JSON, YAML.env 文件。

参数:
  • variables_file_path (str | None) – 包含变量数据的文件位置。

  • connections_file_path (str | None) – 包含连接数据的文件位置。

variables_file = None[source]
connections_file = None[source]
get_connection(conn_id)[source]

返回具有给定 conn_id 的连接对象。

首先尝试 get_conn_value,如果未实现,则尝试 get_conn_uri

参数:

conn_id (str) – 连接 ID

get_variable(key)[source]

返回 Airflow Variable 的值。

参数:

key (str) – 变量键

返回值:

变量值

返回值类型:

str | None

此条目有帮助吗?