Google Cloud BigQuery Data Transfer

3.21.0 · active · verified Sun Mar 29

The Google Cloud BigQuery Data Transfer API client library, currently at version 3.21.0, allows users to programmatically manage scheduled data transfers from various partner SaaS applications and other Google services into Google BigQuery. It enables automation of ETL processes and data replication. The `google-cloud-python` repository, which contains this library, generally follows a regular release cadence with frequent updates across its client libraries.

Warnings

Install

Imports

Quickstart

This quickstart initializes the BigQuery Data Transfer client and lists available data sources within a specified project and location. Replace 'your-project-id' with your actual Google Cloud Project ID, or ensure the GOOGLE_CLOUD_PROJECT environment variable is set. Authentication is handled implicitly via Application Default Credentials (e.g., `gcloud auth application-default login` for local development or service account credentials on Google Cloud infrastructure). Ensure the BigQuery Data Transfer API is enabled in your Google Cloud project.

import os
from google.cloud import bigquery_datatransfer_v1

# Set your Google Cloud Project ID and Location
# For local development, set the GOOGLE_APPLICATION_CREDENTIALS environment variable.
# Example: export GOOGLE_APPLICATION_CREDENTIALS="/path/to/your/key.json"

project_id = os.environ.get("GOOGLE_CLOUD_PROJECT", "your-project-id")
location = "us"

client = bigquery_datatransfer_v1.DataTransferServiceClient()

parent = client.location_path(project_id, location)

try:
    print(f"Listing data sources in project '{project_id}' and location '{location}':")
    for data_source in client.list_data_sources(parent=parent):
        print(f"  Name: {data_source.display_name} (ID: {data_source.data_source_id})")
except Exception as e:
    print(f"Error listing data sources: {e}
Ensure the BigQuery Data Transfer API is enabled for project '{project_id}' and your credentials have sufficient permissions.")

view raw JSON →