简体   繁体   中英

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

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>

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

bq为我考虑的默认项目存储在$HOME/.config/gcloud/configurations/config_default (Linux)

In my case all aforementioned options were overridden by a key "quota_project_id" in ~/.config/gcloud/application_default_credentials.json

"quota_project_id": "my-project",

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