You write a Python script to connect to Google BigQuery from a Google Compute Engine virtual machine. The script is printing errors that it cannot connect to BigQuery. What should you do to fix the script?
Choose an answer
Tap an option to check your answer.
Correct answer: Create a new service account with BigQuery access and execute your script with that user.
Why this is the answer
The most secure and recommended approach is to create a dedicated service account with the necessary BigQuery permissions (e.g., BigQuery Data Editor or BigQuery User) and configure your Compute Engine VM to use this service account. This adheres to the principle of least privilege, ensuring your script only has the permissions it needs. While installing the client library is necessary, the error indicates a connection issue, not a missing library. Running on a new VM with BigQuery access scope enabled is a valid solution, but creating a specific service account offers more granular control and better security practices. Installing the bq component for gcloud is for command-line access, not for Python scripts using client libraries.
Pass your exam — without the endless answer hunt
Get every verified question and explanation for this exam in one place, and save hours of prep. 1,000+ certifications · 20+ languages · free to start.
Pass your exam faster → No card needed