{"id":6655,"library":"google-cloud-bigquery-connection","title":"Google Cloud BigQuery Connection Client Library","description":"The Google Cloud BigQuery Connection API client library (google-cloud-bigquery-connection) is a Python library designed to manage BigQuery connections to external data sources. It provides a programmatic interface for creating, updating, listing, and deleting connections, which are crucial for BigQuery to interact with other Google Cloud services (like Cloud Spanner, Cloud SQL) or external databases. As of April 2026, the current stable version is 1.21.0, and it is actively maintained with regular updates as part of the broader `google-cloud-python` ecosystem.","status":"active","version":"1.21.0","language":"en","source_language":"en","source_url":"https://github.com/googleapis/google-cloud-python/tree/main/packages/google-cloud-bigquery-connection","tags":["google cloud","bigquery","data warehousing","etl","connections","gcp","client library"],"install":[{"cmd":"pip install google-cloud-bigquery-connection","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Requires Python 3.9 or newer.","package":"Python","optional":false},{"reason":"Core dependency for Google Cloud Python client libraries, handles API requests and common client functionality.","package":"google-api-core","optional":false},{"reason":"Manages authentication with Google Cloud services.","package":"google-auth","optional":false}],"imports":[{"note":"The client classes for versioned APIs are typically found under a `_v1` (or `_vX`) submodule for explicit API versioning.","wrong":"from google.cloud.bigquery_connection import BigQueryConnectionServiceClient","symbol":"BigQueryConnectionServiceClient","correct":"from google.cloud.bigquery_connection_v1 import BigQueryConnectionServiceClient"}],"quickstart":{"code":"import os\nfrom google.cloud import bigquery_connection_v1\n\n# It is highly recommended to set the GOOGLE_APPLICATION_CREDENTIALS environment variable\n# to the path of your service account key file for authentication.\n# For example (Linux/macOS): export GOOGLE_APPLICATION_CREDENTIALS=\"/path/to/keyfile.json\"\n# Or set programmatically, but generally discouraged for production:\n# os.environ[\"GOOGLE_APPLICATION_CREDENTIALS\"] = \"/path/to/keyfile.json\"\n\ndef list_bigquery_connections(project_id: str, location: str):\n    \"\"\"Lists all BigQuery connections in a given project and location.\"\"\"\n    client = bigquery_connection_v1.BigQueryConnectionServiceClient()\n    # The parent resource for connections is formatted as 'projects/{project}/locations/{location}'\n    parent = f\"projects/{project_id}/locations/{location}\"\n\n    print(f\"Listing connections in project '{project_id}' at location '{location}':\")\n    try:\n        # API call to list connections\n        for connection in client.list_connections(parent=parent):\n            print(f\"  Connection Name: {connection.name}\")\n            print(f\"    Connection Type: {connection.cloud_resource.connection_type.name}\")\n            print(f\"    Description: {connection.friendly_name or 'N/A'}\")\n            # You can access other connection properties like `cloud_sql` or `aws` here\n    except Exception as e:\n        print(f\"Error listing connections: {e}\")\n        print(\"Please ensure the BigQuery Connection API is enabled for your project \")\n        print(\"and the service account has the 'BigQuery Connection User' role or equivalent permissions.\")\n\n# Replace with your actual project ID and desired location\n# It's best practice to get project_id from the environment or Google Cloud metadata.\nPROJECT_ID = os.environ.get(\"GOOGLE_CLOUD_PROJECT\", \"your-gcp-project-id\")\nLOCATION = \"us\"  # Example: \"us\", \"eu\", \"asia-east1\"\n\nif PROJECT_ID == \"your-gcp-project-id\":\n    print(\"WARNING: Please set the 'GOOGLE_CLOUD_PROJECT' environment variable \")\n    print(\"         or replace 'your-gcp-project-id' with your actual project ID.\")\n    print(\"         Authentication and API calls will likely fail without proper setup.\")\nelse:\n    list_bigquery_connections(PROJECT_ID, LOCATION)","lang":"python","description":"This quickstart demonstrates how to instantiate the BigQuery Connection client and list existing connections within a specified Google Cloud project and location. Authentication is typically handled automatically via Application Default Credentials (ADC) or the `GOOGLE_APPLICATION_CREDENTIALS` environment variable."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or a newer supported version.","message":"The library officially supports Python 3.9 and newer. Older Python versions (3.8 and below) are not supported, and new major versions of Google Cloud client libraries often drop support for end-of-life Python versions.","severity":"breaking","affected_versions":"<1.0.0 (older versions), >=1.0.0 (current)"},{"fix":"Refer to Google Cloud authentication documentation. Ensure the service account used has necessary roles like 'BigQuery Connection User' and 'BigQuery Connection Admin'.","message":"Authentication is a common hurdle. Ensure your environment is correctly set up for Google Cloud authentication (e.g., `GOOGLE_APPLICATION_CREDENTIALS` environment variable pointing to a service account key file, or running in a Google Cloud environment with appropriate service account permissions).","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always construct resource paths carefully following the API's expected format, as specified in the method's documentation.","message":"Many BigQuery Connection API methods (like `list_connections`) require `project_id` and `location` parameters, often combined into a 'parent' resource path (e.g., `projects/{project}/locations/{location}`). Incorrectly formatted resource paths will result in API errors.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Enable the 'BigQuery Connection API' via the Google Cloud Console or `gcloud services enable bigqueryconnection.googleapis.com`.","message":"The BigQuery Connection API must be explicitly enabled in your Google Cloud Project. If not enabled, API calls will result in 'API not enabled' or similar permission errors.","severity":"gotcha","affected_versions":"All versions"},{"fix":"If encountering unexpected errors, try pinning `google-api-core` to a slightly older version (e.g., `pip install google-api-core==1.33.2`) or ensure all `google-cloud-*` libraries are updated to their latest versions.","message":"In the broader Google Cloud client ecosystem, version incompatibilities can occur between `google-api-core` and specific `google-cloud-*` client libraries. For instance, `google-api-core==1.34.0` caused issues with older `google-cloud-bigquery` versions.","severity":"gotcha","affected_versions":"Potentially specific minor versions of `google-cloud-bigquery-connection` with `google-api-core`"}],"env_vars":null,"last_verified":"2026-04-15T00:00:00.000Z","next_check":"2026-07-14T00:00:00.000Z","problems":[]}