Microsoft SQL Server 到 Google Cloud Storage Operator¶
Google Cloud Storage (GCS) 服務用於儲存來自各種應用程式的大量資料。本頁介紹如何將資料從 Microsoft SQL Server 複製到 GCS。
先決任務¶
要使用這些 Operator,您需要做幾件事
使用 Cloud Console 選擇或建立 Cloud Platform 專案。
為您的專案啟用結算功能,詳見 Google Cloud 文件。
啟用 API,詳見 Cloud Console 文件。
透過 pip 安裝 API 庫。
pip install 'apache-airflow[google]'詳細資訊請參閱 安裝。
MSSQLToGCSOperator¶
MSSQLToGCSOperator 允許您將資料從 Microsoft SQL Server 資料庫上傳到 GCS。
以下是使用此 Operator 將資料上傳到 GCS 的示例。
tests/system/google/cloud/gcs/example_mssql_to_gcs.py
upload_mssql_to_gcs = MSSQLToGCSOperator(
task_id="mssql_to_gcs",
mssql_conn_id="airflow_mssql",
sql=SQL_QUERY,
bucket=BUCKET_NAME,
filename=FILENAME,
export_format="csv",
)
參考¶
更多資訊,請參閱: * Microsoft SQL Server 文件 * Google Cloud Storage 文件