[英]How to get names of scheduled queries in bigquery
Using a python client to connect with bigquery, how can we get names of all the scheduled queries present in that project?使用 python 客户端连接 bigquery,我们如何获取该项目中存在的所有计划查询的名称?
I tried following up with this link - https://cloud.google.com/bigquery/docs/reference/datatransfer/libraries我尝试跟进此链接 - https://cloud.google.com/bigquery/docs/reference/datatransfer/libraries
But got no information on the names of the scheduled queries.但是没有关于预定查询名称的信息。
To list all the scheduled queries for a project with Python
BigQuery
Client
:要使用
Python
BigQuery
Client
列出项目的所有计划查询:
def get_scheduled_queries_configs():
from google.cloud import bigquery_datatransfer
transfer_client = bigquery_datatransfer.DataTransferServiceClient()
project_id = "{project_id}"
parent = transfer_client.common_location_path(project=project_id, location='EU')
request = bigquery_datatransfer.ListTransferConfigsRequest(
parent=parent,
data_source_ids=['scheduled_query']
)
configs = transfer_client.list_transfer_configs(request=request)
print("Got the following configs:")
for config in configs:
print(f"\tID: {config.name}, Schedule: {config.schedule}")
print(f"\tDisplay name: {config.display_name}")
config_name = config.name
config_schedule = config.schedule
config_display_name = config.display_name
return configs
if __name__ == '__main__':
scheduled_queries_configs = get_scheduled_queries_configs()
Some explanations:一些解释:
transfer configs
only for scheduled queries via ListTransferConfigsRequest
object. The request takes the parent argument containing the project and the location EU
in this example.ListTransferConfigsRequest
object 检索计划查询的transfer configs
。在本示例中,该请求采用包含项目和位置EU
的父参数。 The request take also data_source_ids
argument with scheduled_query
valuescheduled_query
值的data_source_ids
参数config.display_name
allows to retrieve the name of a scheduled query config.display_name
允许检索计划查询的名称
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.