Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

License

NotificationsYou must be signed in to change notification settings

googleapis/python-bigquery

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

GApypiversions

Querying massive datasets can be time consuming and expensive without theright hardware and infrastructure. GoogleBigQuery solves this problem byenabling super-fast, SQL queries against append-mostly tables, using theprocessing power of Google's infrastructure.

Quick Start

In order to use this library, you first need to go through the following steps:

  1. Select or create a Cloud Platform project.
  2. Enable billing for your project.
  3. Enable the Google Cloud BigQuery API.
  4. Setup Authentication.

Installation

Install this library in avirtualenv using pip.virtualenv is a tool tocreate isolated Python environments. The basic problem it addresses is one ofdependencies and versions, and indirectly permissions.

Withvirtualenv, it's possible to install this library without needing systeminstall permissions, and without clashing with the installed systemdependencies.

Supported Python Versions

Python >= 3.7, < 3.11

Unsupported Python Versions

Python == 2.7, Python == 3.5, Python == 3.6.

The last version of this library compatible with Python 2.7 and 3.5 isgoogle-cloud-bigquery==1.28.0.

Mac/Linux

pip install virtualenvvirtualenv <your-env>source <your-env>/bin/activate<your-env>/bin/pip install google-cloud-bigquery

Windows

pip install virtualenvvirtualenv <your-env><your-env>\Scripts\activate<your-env>\Scripts\pip.exe install google-cloud-bigquery

Example Usage

Perform a query

fromgoogle.cloudimportbigqueryclient=bigquery.Client()# Perform a query.QUERY= ('SELECT name FROM `bigquery-public-data.usa_names.usa_1910_2013` ''WHERE state = "TX" ''LIMIT 100')query_job=client.query(QUERY)# API requestrows=query_job.result()# Waits for query to finishforrowinrows:print(row.name)

Instrumenting With OpenTelemetry

This application usesOpenTelemetry to output tracing data fromAPI calls to BigQuery. To enable OpenTelemetry tracing inthe BigQuery client the following PyPI packages need to be installed:

pip install google-cloud-bigquery[opentelemetry] opentelemetry-exporter-google-cloud

After installation, OpenTelemetry can be used in the BigQueryclient and in BigQuery jobs. First, however, an exporter must bespecified for where the trace data will be outputted to. Anexample of this can be found here:

fromopentelemetryimporttracefromopentelemetry.sdk.traceimportTracerProviderfromopentelemetry.sdk.trace.exportimportBatchExportSpanProcessorfromopentelemetry.exporter.cloud_traceimportCloudTraceSpanExportertrace.set_tracer_provider(TracerProvider())trace.get_tracer_provider().add_span_processor(BatchExportSpanProcessor(CloudTraceSpanExporter()))

In this example all tracing data will be published to the GoogleCloud Trace console. For more information on OpenTelemetry, please consult theOpenTelemetry documentation.

About

No description, website, or topics provided.

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp