2

我想在本地测试 BigQuery DataTransfer API,但遇到库问题:

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)

以下是遇到的问题:

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

和 :

Unexpected keyword argument 'requested_run_time' in method call
4

1 回答 1

1

为了进一步为社区做出贡献,我将我的建议作为答案发布。有一次,你提到它对你有用。

根据文档,您应该按如下方式导入Timestamp包,

from google.protobuf.timestamp_pb2 import Timestamp

之后,您将能够google.protobuf.timestamp_pb2.Timestamp按照您在代码中编写的方式使用它。导入正确的包后,这两个错误都不会发生。

于 2021-04-09T05:48:46.217 回答