简体   繁体   中英

DataTransferService API - Module 'google.cloud.bigquery_datatransfer_v1.types' has no 'Timestamp'

I want to test BigQuery DataTransfer API in local but I encounter problems with library:

client = bigquery_datatransfer_v1.DataTransferServiceClient()
projectid = 'MyProjectID' 
transferid = 'MyTransferID'  
parent = client.transfer_config_path(projectid, transferid)
start_time = bigquery_datatransfer_v1.types.Timestamp(seconds=int(time.time() + 10))
response = client.start_manual_transfer_runs(parent, requested_run_time=start_time)
print(response)

Here are the problems encountered:

Module 'google.cloud.bigquery_datatransfer_v1.types' has no 'Timestamp'

And:

Unexpected keyword argument 'requested_run_time' in method call

In order to further contribute to the community, I am posting my suggestion as an answer. Once, you mentioned it worked for you.

As per the documentation, you should import the Timestamp package as follows,

from google.protobuf.timestamp_pb2 import Timestamp

After that, you will be able to use it as google.protobuf.timestamp_pb2.Timestamp or as you wrote in your code. Both errors won't happen after you import the correct package.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM