Metadata-Version: 2.0
Name: jsontableschema-bigquery
Version: 0.4.3
Summary: Generate BigQuery tables, load and extract data, based on JSON Table Schema descriptors.
Home-page: https://github.com/frictionlessdata/jsontableschema-bigquery-py
Author: Open Knowledge Foundation
Author-email: info@okfn.org
License: MIT
Keywords: frictionless data
Platform: UNKNOWN
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Web Environment
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Dist: google-api-python-client (>=1.5,<2.0)
Requires-Dist: jsontableschema (>=0.7,<2.0)
Requires-Dist: python-slugify (>=1.2,<2.0)
Requires-Dist: six (>=1.9,<2.0)
Requires-Dist: tabulator (>=0.7,<2.0)
Requires-Dist: unicodecsv (>=0.14,<2.0)
Provides-Extra: develop
Requires-Dist: pylama; extra == 'develop'
Requires-Dist: tox; extra == 'develop'

jsontableschema-bigquery-py
===========================

| |Travis|
| |Coveralls|
| |PyPi|
| |SemVer|
| |Gitter|

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

    Version ``v0.3`` contains breaking changes:

-  renamed ``Storage.tables`` to ``Storage.buckets``
-  changed ``Storage.read`` to read into memory
-  added ``Storage.iter`` to yield row by row

Getting Started
---------------

Installation
~~~~~~~~~~~~

.. code:: bash

    pip install jsontableschema-bigquery

Storage
~~~~~~~

Package implements `Tabular
Storage <https://github.com/frictionlessdata/jsontableschema-py#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:

.. code:: 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:

.. code:: python

    storage.buckets
    storage.create('bucket', descriptor)
    storage.delete('bucket')
    storage.describe('bucket') # return descriptor
    storage.iter('bucket') # yields rows
    storage.read('bucket') # return rows
    storage.write('bucket', rows)

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/>`__.

API Reference
-------------

Snapshot
~~~~~~~~

https://github.com/frictionlessdata/jsontableschema-py#snapshot

Detailed
~~~~~~~~

-  `Docstrings <https://github.com/frictionlessdata/jsontableschema-py/tree/master/jsontableschema/storage.py>`__
-  `Changelog <https://github.com/frictionlessdata/jsontableschema-bigquery-py/commits/master>`__

Contributing
------------

Please read the contribution guideline:

`How to Contribute <CONTRIBUTING.md>`__

Thanks!

.. |Travis| image:: https://img.shields.io/travis/frictionlessdata/jsontableschema-bigquery-py/master.svg
   :target: https://travis-ci.org/frictionlessdata/jsontableschema-bigquery-py
.. |Coveralls| image:: http://img.shields.io/coveralls/frictionlessdata/jsontableschema-bigquery-py.svg?branch=master
   :target: https://coveralls.io/r/frictionlessdata/jsontableschema-bigquery-py?branch=master
.. |PyPi| image:: https://img.shields.io/pypi/v/jsontableschema-bigquery.svg
   :target: https://pypi.python.org/pypi/jsontableschema-bigquery
.. |SemVer| image:: https://img.shields.io/badge/versions-SemVer-brightgreen.svg
   :target: http://semver.org/
.. |Gitter| image:: https://img.shields.io/gitter/room/frictionlessdata/chat.svg
   :target: https://gitter.im/frictionlessdata/chat

