Python Client for Google BigQuery
Project description
Python idiomatic client for Google BigQuery
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
Built Distribution
Hashes for google-cloud-bigquery-0.24.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3455d9ba66c876a37ff73108a95771edce4e082537d6119c19dcc1371f1b086a |
|
MD5 | 7ce1243eb1a1289b79a5bff592639109 |
|
BLAKE2b-256 | c1fc91a8665f9ec8e5e251fa54f7e775f9c744fef7e65168431b04fb97a904de |
Hashes for google_cloud_bigquery-0.24.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a251d169a6bf4efdb48dc98c95d704598512104d021fa5b444ed1e19c4166979 |
|
MD5 | 56b4a59e02b086fc480cbd6ec363b08f |
|
BLAKE2b-256 | 6a950b34c7736a730c149f347e3277ab7873bd156849f89b0240ed5f1833c2d2 |