Skip to main content

Python Client for Google BigQuery

Project description

Python idiomatic client for Google BigQuery

pypi versions

Quick Start

$ pip install --upgrade google-cloud-bigquery

Authentication

With google-cloud-python we try to make authentication as painless as possible. Check out the Authentication section in our documentation to learn more. You may also find the authentication document shared by all the google-cloud-* libraries to be helpful.

Using the API

Querying massive datasets can be time consuming and expensive without the right hardware and infrastructure. Google BigQuery (BigQuery API docs) solves this problem by enabling super-fast, SQL-like queries against append-only tables, using the processing power of Google’s infrastructure.

Load data from CSV

import csv

from google.cloud import bigquery
from google.cloud.bigquery import SchemaField

client = bigquery.Client()

dataset = client.dataset('dataset_name')
dataset.create()  # API request

SCHEMA = [
    SchemaField('full_name', 'STRING', mode='required'),
    SchemaField('age', 'INTEGER', mode='required'),
]
table = dataset.table('table_name', SCHEMA)
table.create()

with open('csv_file', 'rb') as readable:
    table.upload_from_file(
        readable, source_format='CSV', skip_leading_rows=1)

Perform a synchronous query

# Perform a synchronous query.
QUERY = (
    'SELECT name FROM [bigquery-public-data:usa_names.usa_1910_2013] '
    'WHERE state = "TX"')
query = client.run_sync_query('%s LIMIT 100' % QUERY)
query.timeout_ms = TIMEOUT_MS
query.run()

for row in query.rows:
    print(row)

See the google-cloud-python API BigQuery documentation to learn how to connect to BigQuery using this Client Library.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

google-cloud-bigquery-0.27.0.tar.gz (95.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

google_cloud_bigquery-0.27.0-py2.py3-none-any.whl (54.6 kB view details)

Uploaded Python 2Python 3

File details

Details for the file google-cloud-bigquery-0.27.0.tar.gz.

File metadata

File hashes

Hashes for google-cloud-bigquery-0.27.0.tar.gz
Algorithm Hash digest
SHA256 d12550f7bd54cb89ed026f0fd8ac3bc9b6cab9e3ff67f7310b149cca8e4ba5ad
MD5 1b4f9d8f64f0a82a86fb713fe09cebdd
BLAKE2b-256 1e5ec1428a43af9562711130296d517fc86c8006c60593d13027fa8701cd6e26

See more details on using hashes here.

File details

Details for the file google_cloud_bigquery-0.27.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for google_cloud_bigquery-0.27.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 ad86defd25dcb704200e50b3950ade85f4e7fba6d8c209c12f5cd1d46ddffa9b
MD5 9eb7b042463b16145882a0f5238ac05b
BLAKE2b-256 0ca42be9287b773adfc68114e83c9617c9a78a44785659e48c4194504fcfa6f6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page