简体   繁体   English

如何使用bigquery_datatransfer Python客户端创建AdWords BigQuery传输和传输运行?

[英]How do you create a Adwords BigQuery Transfer and Transfer Runs using the bigquery_datatransfer Python client?

I have been able to successfully authenticate, and list transfers and transfer runs. 我已经能够成功进行身份验证,并列出传输和传输运行。 But I keep running into the issue of not being able to create a transfer because the transfer config is incorrect. 但是我一直遇到由于传输配置不正确而无法创建传输的问题。

Here's the Transfer Config I have tried: 这是我尝试过的传输配置:

transferConfig = {
    'data_refresh_window_days': 1,
    'data_source_id': "adwords",
    'destination_dataset_id': "AdwordsMCC",
    'disabled': False,
    'display_name': "TestR",
    'name': "TestR",
    'schedule': "every day 07:00",
    'params': {
        "customer_id": "999999999" -- Changed Number
    }
}

response = client.create_transfer_config(parent, transferConfig)
print(response)

And this is the error I get: 这是我得到的错误:

Traceback (most recent call last):
File "./create_transfer.py", line 84, in <module>
    main()
File "./create_transfer.py", line 61, in main
    response = client.create_transfer_config(parent, transferConfig)
File "/usr/local/Cellar/python3/3.6.2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/google/cloud/bigquery_datatransfer_v1/gapic/data_transfer_service_client.py", line 438, in create_transfer_config
    authorization_code=authorization_code)
ValueError: Protocol message Struct has no "customer_id" field.
DDIS:bigquery siddharthsudheer$ ./create_transfer.py
Traceback (most recent call last):
File "./create_transfer.py", line 84, in <module>
    main()
File "./create_transfer.py", line 61, in main
    response = client.create_transfer_config(parent, transferConfig)
File "/usr/local/Cellar/python3/3.6.2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/google/cloud/bigquery_datatransfer_v1/gapic/data_transfer_service_client.py", line 438, in create_transfer_config
    authorization_code=authorization_code)
ValueError: Protocol message Struct has no "customer_id" field.

I managed to set up a Data Transfer through the API by defining the params as class google.protobuf.struct_pb2.Struct . 通过将params定义为google.protobuf.struct_pb2.Struct类,我设法通过API设置了数据传输。

Try if the adding the following works for you: 尝试添加以下内容是否适合您:

from google.protobuf.struct_pb2 import Struct

params = Struct()
params["customer_id"] = "999999999"

And then changing your transferConfig to: 然后将您的transferConfig更改为:

transferConfig = {
    'data_refresh_window_days': 1,
    'data_source_id': "adwords",
    'destination_dataset_id': "AdwordsMCC",
    'disabled': False,
    'display_name': "TestR",
    'name': "TestR",
    'schedule': "every day 07:00",
    'params': params
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 Python bigquery_datatransfer 创建 Adwords BigQuery Transfer:错误 400 请求包含无效参数 - Create adwords BigQuery Transfer with Python bigquery_datatransfer: error 400 Request contains an invalid argument 如何使用 Python 创建 BigQuery 数据传输服务 - How to create BigQuery Data Transfer Service using Python BigQuery数据传输服务-python客户端库 - BigQuery Data Transfer Services - python client library 如何使用 Python + 服务帐户创建 BigQuery 数据传输? - How to create BigQuery Data Transfer w/ Python + Service Account? 在 python 中使用谷歌数据流进行 Bigquery 到 Bigtable 的数据传输 - Bigquery to Bigtable data transfer using google dataflow in python BigQuery到Hadoop群集-如何传输数据? - BigQuery to Hadoop Cluster - How to transfer data? 获取禁止:403 访问被拒绝,当请求使用 python 将数据从谷歌云存储传输到 bigquery 时 - get Forbidden: 403 Access Denied when do request to transfer data from google cloud storage to bigquery using python 如何使用Python传输二进制数据? - How do you transfer binary data with Python? 如何使用 python 客户端库处理 bigquery 中简单选择的大型查询结果? - How do you handle large query results for a simple select in bigquery with the python client library? 您如何以编程方式创建Google BigQuery架构以创建表? - How do you programmatically create a Google BigQuery schema to create a table?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM