Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I change the project in BigQuery

When configuring the Big-Query command line tool I was asked to set up a default project. However, now I have many projects and I can't happen to find how do I switch from one project to the other. Does someone know how to navigate the projects using the command line? Thanks in advance!

G

like image 920
Gallory Knox Avatar asked Apr 17 '16 14:04

Gallory Knox


People also ask

How do I change the project ID in BigQuery?

No, you cannot change the project id. But in BigQuery UI, you can omit the "project_id:" part, and it will query the table in your current project.

How do I change my project ID?

A project ID cannot be changed after the project is created, so if you are creating a new project, be sure to choose an ID that you'll be comfortable using for the lifetime of the project.

How do you set a project as the default for the bq command line tool?

Running the bq command-line tool in an interactive shellTo start interactive mode, enter bq shell . After launching the shell, the prompt changes to the ID of your default project. To exit interactive mode, enter exit .


2 Answers

You have two ways to do it:

  • Specify --project_id global flag in bq. Example: bq ls -j --project_id <PROJECT>
  • Change default project by issuing gcloud config set project <PROJECT>
like image 164
asamarin Avatar answered Sep 21 '22 12:09

asamarin


We were also facing the same issue, and tried the setting --project_id param and default project using gcloud config set project command, but no luck.

Then we created the .bigqueryrc file and passed the path via --bigqueryrc flag, it worked.

content of the .bigqueryrc file

--project_id=gcp_project_id

Example:

bq --bigqueryrc=/path_to_file/.bigqueryrc ls -j 

https://cloud.google.com/bigquery/docs/bq-command-line-tool#setting_default_values_for_command-line_flags

like image 24
SANN3 Avatar answered Sep 21 '22 12:09

SANN3