在气流中从 GCS 写入 Postgresql 的大多数 python 方式

Most python way to write from GCS to Postgresql in airflow

我正在构建一个气流 dag,它从 GCS 获取 csv 文件并将它们插入云 SQL 中的 postgresql table。我有几个选择:

哪种方法最符合 Python 风格?

你应该选择 COPY。

https://www.postgresql.org/docs/current/sql-copy.html

COPY 在 PostgreSQL tables 和标准文件系统文件之间移动数据。 COPY TO 将 table 的内容复制到文件,而 COPY FROM 将数据从文件复制到 table(将数据附加到 table 中已有的内容)。