繁体   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