Postgres 到 Google Cloud Storage Operator

Google Cloud Storage (GCS) 服務用於儲存來自各種應用程式的大量資料。本頁展示瞭如何將資料從 Postgres 複製到 GCS。

先決條件任務

要使用這些 operators,您必須執行以下幾項操作:

PostgresToGCSOperator

PostgresToGCSOperator 允許您將資料從 Postgres 資料庫上傳到 GCS。

使用此 operator 時,您可以選擇將要上傳的資料壓縮為 gzip 格式。

以下是使用此 operator 將資料上傳到 GCS 的示例。

tests/system/google/cloud/transfers/example_postgres_to_gcs.py

    postgres_to_gcs = PostgresToGCSOperator(
        task_id="postgres_to_gcs",
        postgres_conn_id=CONNECTION_ID,
        sql=SQL_SELECT,
        bucket=BUCKET_NAME,
        filename=FILE_NAME,
        export_format="csv",
    )

參考

更多資訊,請參閱: * Google Cloud Storage 文件

此條目是否有幫助?