The BigQuery CLI (bq) is a command-line tool for managing datasets, running queries, and administering Google BigQuery projects.
The bq CLI lets you create datasets, load data, and run SQL queries from any terminal. It supports scripting, automation, and CI/CD workflows.
Install Python 3.8+, have a Google Cloud account with BigQuery API enabled, and ensure you can run admin commands (sudo or elevated PowerShell).
Run brew install --cask google-cloud-sdk
, then gcloud components install bq
. Homebrew handles path updates automatically.
Use the MSI installer from Google Cloud or run choco install gcloudsdk
in an elevated PowerShell, then execute gcloud components install bq
.
Add Google’s repo, update apt, then run sudo apt-get install google-cloud-cli
. Finish with gcloud components install bq
.
Add the YUM repo, sudo dnf install google-cloud-cli
, and enable bq with gcloud components install bq
.
Run bq version
. A proper install returns the CLI version and the underlying Python version.
Execute gcloud auth login
, select your Google account, then set a default project via gcloud config set project my-project-id
.
Run bq query --use_legacy_sql=false "SELECT COUNT(*) AS customers FROM `my_project.ecommerce.Customers`;"
to confirm connectivity.
Pin versions in CI images, use service-account JSON keys for automation, and add --format=json
for script-friendly output.
Always run gcloud components update
before debugging, and ensure the BigQuery API is enabled in the Cloud Console.
Use bq help
for command reference or visit the Google Cloud docs for advanced examples.
No. The bq component is distributed as part of the Cloud SDK. You must install the SDK, then add bq.
Yes. Run gcloud auth activate-service-account --key-file=key.json
and set the project to use non-interactive automation.
Run gcloud components update
. Homebrew, Chocolatey, and package manager installs fetch a newer SDK, then update bq automatically.