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
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.
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.
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 .
You have two ways to do it:
--project_id
global flag in bq
. Example: bq ls -j --project_id <PROJECT>
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With