Skip to main content

Generate BigQuery tables, load and extract data, based on JSON Table Schema descriptors.

Project description

# jsontableschema-bigquery-py

[![Travis](https://img.shields.io/travis/frictionlessdata/jsontableschema-bigquery-py.svg)](https://travis-ci.org/frictionlessdata/jsontableschema-bigquery-py)
[![Coveralls](http://img.shields.io/coveralls/frictionlessdata/jsontableschema-bigquery-py.svg?branch=master)](https://coveralls.io/r/frictionlessdata/jsontableschema-bigquery-py?branch=master)
[![PyPi](https://img.shields.io/pypi/v/jsontableschema-bigquery.svg)](https://pypi.python.org/pypi/jsontableschema-bigquery)
[![Gitter](https://img.shields.io/gitter/room/frictionlessdata/chat.svg)](https://gitter.im/frictionlessdata/chat)

Generate and load BigQuery tables based on JSON Table Schema descriptors.

## Tabular Storage

Package implements [Tabular Storage](https://github.com/okfn/datapackage-storage-py#tabular-storage) interface.

To start using Google BigQuery service:
- Create a new project - [link](https://console.developers.google.com/home/dashboard)
- Create a service key - [link](https://console.developers.google.com/apis/credentials)
- Download json credentials and set `GOOGLE_APPLICATION_CREDENTIALS` environment variable

We can get storage this way:

```python
import io
import os
import json
from apiclient.discovery import build
from oauth2client.client import GoogleCredentials
from jsontableschema_bigquery import Storage

os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = '.credentials.json'
credentials = GoogleCredentials.get_application_default()
service = build('bigquery', 'v2', credentials=credentials)
project = json.load(io.open('.credentials.json', encoding='utf-8'))['project_id']
storage = Storage(service, project, 'dataset', prefix='prefix')
```

Then we could interact with storage:

```python
storage.tables
storage.check('table_name') # check existence
storage.create('table_name', schema)
storage.delete('table_name')
storage.describe('table_name') # return schema
storage.read('table_name') # return data
storage.write('table_name', data)
```

## Mappings

```
schema.json -> bigquery table schema
data.csv -> bigquery talbe data
```

## Drivers

Default Google BigQuery client is used - [docs](https://developers.google.com/resources/api-libraries/documentation/bigquery/v2/python/latest/).

## Documentation

API documentation is presented as docstings:
- [Storage](https://github.com/frictionlessdata/jsontableschema-bigquery-py/blob/master/jsontableschema_bigquery/storage.py)

## Contributing

Please read the contribution guideline:

[How to Contribute](CONTRIBUTING.md)

Thanks!

Project details


Download files

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

Source Distribution

jsontableschema-bigquery-0.2.0.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

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

jsontableschema_bigquery-0.2.0-py2.py3-none-any.whl (8.9 kB view details)

Uploaded Python 2Python 3

File details

Details for the file jsontableschema-bigquery-0.2.0.tar.gz.

File metadata

File hashes

Hashes for jsontableschema-bigquery-0.2.0.tar.gz
Algorithm Hash digest
SHA256 4a1d95f91ba99d5f3f77a05f312dc09d6aceaa5da48b9e4a29189b1407cc09a7
MD5 2ec6b5d1b17d2cfdd479b17e822f2d23
BLAKE2b-256 61fe466334246d577ed65ee44452e30c8336c680b29a68ea389333719e4910f3

See more details on using hashes here.

File details

Details for the file jsontableschema_bigquery-0.2.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for jsontableschema_bigquery-0.2.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 4b8a24f724a8db06c2b627667c5374dc964bc9c411011fcfa666eee726d8d0c0
MD5 755881214b6e7e5d7500c41053e91eeb
BLAKE2b-256 2f833ae5da1104c49cca90e51de0bc609a0e468ba37cd4bf5feb242ef8156cf0

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