Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DX docs for managing datasets #986

Merged
merged 2 commits into from
Jul 20, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions docs/bigquery-usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,69 @@ Authorization / Configuration

>>> from gcloud import bigquery
>>> client = bigquery.Client(project='PROJECT_ID')


Manage datasets

This comment was marked as spam.

This comment was marked as spam.

---------------

Create a new dataset for the client's project:

.. doctest::

>>> from gcloud import bigquery

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

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

Check for the existence of a dataset:

.. doctest::

>>> from gcloud import bigquery
>>> client = bigquery.Client()
>>> dataset = client.dataset('dataset_name')

This comment was marked as spam.

This comment was marked as spam.

>>> dataset.exists() # API request
True

List datasets for the client's project:

.. doctest::

>>> from gcloud import bigquery
>>> client = bigquery.Client()
>>> datasets, next_page_token = client.list_datasets() # API request
>>> [dataset.name for dataset in datasets]
['dataset_name']

Patch metadata for a dataset:

.. doctest::

>>> from gcloud import bigquery
>>> client = bigquery.Client()
>>> dataset = client.dataset('dataset_name')
>>> one_day_ms = 24 * 60 * 60 * 1000
>>> dataset.patch(description='Description goes here',
... default_table_expiration_ms=one_day_ms) # API request

This comment was marked as spam.

This comment was marked as spam.


Replace the ACL for a project, and update all writeable fields:

.. doctest::

>>> from gcloud import bigquery
>>> client = bigquery.Client()
>>> dataset = client.dataset('dataset_name')
>>> dataset.get() # API request
>>> acl = list(dataset.acl)
>>> acl.append(bigquery.Access(role='READER', entity_type='domain', entity='example.com'))

This comment was marked as spam.

>>> dataset.acl = acl

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

>>> dataset.update() # API request

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.


Delete a dataset:

.. doctest::

>>> from gcloud import bigquery
>>> client = bigquery.Client()
>>> dataset = client.dataset('dataset_name')
>>> dataset.delete() # API request