Nic*_*ell 6 python google-api google-bigquery google-cloud-platform
我已经设置了我的服务帐户,我可以使用在 bigQuery 上运行查询client.query()。
我可以将所有计划查询写入这种新client.query()格式,但我已经有许多计划查询,所以我想知道是否有一种方法可以获取/列出计划查询,然后使用该信息从脚本运行这些查询。
是的,您可以使用 API。当你不知道该使用哪一个时,我有一个提示。使用@Yev建议的命令
bq ls --transfer_config --transfer_location=US --format=prettyjson
但记录 API 调用。为此使用--apilog <logfile name>这样的参数
bq --apilog ./log ls --transfer_config --transfer_location=US --format=prettyjson
而且,神奇的是,您可以找到该命令调用的 API:
https://bigquerydatatransfer.googleapis.com/v1/projects/<PROJECT-ID>/locations/US/transferConfigs?alt=json
然后,简单的谷歌搜索就会引导您找到正确的文档
requirements.txt在 python 中,在:中添加依赖项google-cloud-bigquery-datatransfer并使用该代码
from google.cloud import bigquery_datatransfer
client = bigquery_datatransfer.DataTransferServiceClient()
parent = client.common_project_path("<PROJECT-ID>")
resp = client.list_transfer_configs(parent=parent)
print(resp)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1948 次 |
| 最近记录: |