将所有气流连接导出到新环境

编程入门 行业动态 更新时间:2024-10-14 08:22:24
本文介绍了将所有气流连接导出到新环境的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试将所有现有的气流连接迁移到新的气流。

I'm trying to migrate all the existing airflow connections to a new airflow.

我在查看cli选项气流连接--help ,它提供了一个列出选项,但没有

I was looking at the cli options airflow connections --help, it gives an option to list but doesn't give an option to export/import to/from json format.

是否可以通过cli / airflow ui跨多种气流迁移连接?

Is there a way via cli/airflow ui to migrate connections across multiple airflows?

推荐答案

您可以直接连接到Airflow元数据库并转储那些连接,然后将它们加载到单独的数据库中。 但是,如果要自动化这样的操作,可以先将它们转储到CSV文件中:

You can either connect directly to the Airflow meta db and dump those connections, then load them in a separate database. However, if you want to automate something like this, you can get started by dumping them in a CSV file:

from airflow.utils import db from airflow.models import Connection import csv outfile = open('myconnections.csv', 'w') outcsv = csv.writer(outfile) with db.create_session() as session: connections = session.query(Connection).all() conn_list = [ [getattr(c, column.name) for column in Connection.__mapper__.columns] for c in connections ] outcsv.writerows(conn_list) outfile.close()

之后,您可以将其加载到

After that, you can load that to a new DB manually or with a similar script.

重要:如果启用了加密,则为这些连接存储的密码将被加密,并且当您将它们加载到新数据库时,必须使用相同的Fernet密钥,否则您将不会成为可以解密它们。

IMPORTANT: if you have enabled encryption, the passwords stored for these connections will be encrypted, and when you load them to the new DB, you must use the identical fernet key, or otherwise you won't be able to decrypt them.

更多推荐

将所有气流连接导出到新环境

本文发布于:2023-11-24 00:18:23,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1623288.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:气流   到新   环境

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!