2

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
Nimantha
  • 6,405
  • 6
  • 28
  • 69
Sara
  • 21
  • 2
  • According to the [documentation](https://googleapis.dev/python/bigquerydatatransfer/latest/bigquery_datatransfer_v1/data_transfer_service.html?highlight=google%20protobuf%20timestamp_pb2) you should import the `Timestamp` package as follows, `from google.protobuf.timestamp_pb2 import Timestamp`. Then you will be able to use it as `google.protobuf.timestamp_pb2.Timestamp)` or as you wrote in your code. Did it work for you? – Alexandre Moraes Apr 08 '21 at 11:30
  • Thank you it works ! I have an other question : Did you already used the StartManualTransferRuns method ? I want to run a BigQuery scheduled queries I test this in function : response = google.cloud.bigquery_datatransfer_v1.types.datatransfer.StartManualTransferRunsResponse(parent, requested_run_time=start_time) but it doesn't works – Sara Apr 08 '21 at 13:39
  • I have posted an answer since you mentioned it worked. If you found the information useful, please accept and upvote the answer. Regarding your new question, could you please post another question ? So we dedicate a new thread to this new issue, where you will describe your goal and share the error message you received. I will be glad to help :) – Alexandre Moraes Apr 09 '21 at 05:51
  • I posted the question about StartManualTransferRuns method : https://stackoverflow.com/questions/67017317/data-transfer-service-api-start-manual-transfer-runs-method – Sara Apr 12 '21 at 07:33

1 Answers1

1

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.

Alexandre Moraes
  • 3,892
  • 1
  • 6
  • 13