【问题标题】:Postgres for Airflow backend DB to create metadata tables in a specified schema用于 Airflow 后端数据库的 Postgres 在指定模式中创建元数据表
【发布时间】:2021-03-24 09:51:45
【问题描述】:

我正在使用以下 sqlalchemy 连接字符串为 Airflow 元数据数据库设置 postgres 后端:

sql_alchemy_conn = postgresql+psycopg2://<user>:<pass>@<host>:5432/<db>

当我运行 initdb/upgradedb 时,表是在公共架构中创建的。

有没有办法在指定的架构中创建表?

能否将我希望创建表的架构指定为连接字符串的一部分?

【问题讨论】:

    标签: postgresql sqlalchemy airflow psycopg2


    【解决方案1】:

    来自the docs

    另外请注意,由于 SqlAlchemy 没有公开针对 Postgres 连接 URI 中特定模式的方法,您可能希望使用类似于 ALTER ROLE username SET search_path = airflow, foobar; 的命令为您的角色设置默认模式。

    所以,连接到 postgres,并为您的用户设置搜索路径。

    【讨论】:

      猜你喜欢
      • 2012-08-10
      • 1970-01-01
      • 2019-03-30
      • 2017-07-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-25
      相关资源
      最近更新 更多