簡體   English   中英

GCP - 將數據從 REST API 插入/加載到 BigQuery,使用 Google Cloud Function 和 ZA7F5F35426B927824717BFCFC11

[英]GCP - Insert/Load Data to BigQuery from REST API using Google Cloud Function with Python

Is it possible to directly insert/stream data from a rest api with json output to bigquery in gcp using cloud function?

做一些研究,但它總是要求放入 GCS 存儲桶,然后創建雲 function 以將數據加載到 bigquery。

提前致謝。

是的,您無需通過 GCS 即可加載它。 使用本教程作為指南(使用 JSON 文件)將我們帶到此源代碼(由教程中的雲 Function 使用),您可以看到它所做的只是將存儲桶文件加載到一個 blob 中,然后加載到 Z466DEEC76ECDF54DCA54332:

row = json.loads(blob.download_as_string())

之后只需使用insert_rows_json方法即可:

BQ.insert_rows_json(table, json_rows=[row],
                             row_ids=[file_name],
                             retry=retry.Retry(deadline=30))

So, you can just send from your API the requests with a POST to a HTTP Cloud Function and that function use the above code to load the json fo BigQuery.

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM