Postgres 至 Google Cloud Storage Operator

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

先決條件任務

要使用這些運算子,您必須執行一些操作

PostgresToGCSOperator

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

當您使用此運算子時,您可以選擇性地壓縮要上傳到 gzip 格式的資料。

以下是使用此運算子將資料上傳到 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 文件

此條目是否有幫助?