Skip to content

Commit 9108464

Browse files
authored
Move usage guides to their own docs. (googleapis#6238)
* Move usage guides to their own docs. The API reference links were buried behind pages of code samples. Moving the how-to guides to their own pages makes the documentation easier to navigate. * Reorganize howto guides into sections. Add links to relevant methods. * Move 'more examples' to bottom of the examples section. Add section headers to Dataset how-to guides. * Move howto to usage directory
1 parent 333c52a commit 9108464

File tree

11 files changed

+481
-446
lines changed

11 files changed

+481
-446
lines changed

bigquery/README.rst

Lines changed: 2 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -74,56 +74,15 @@ Windows
7474
Example Usage
7575
-------------
7676

77-
Create a dataset
78-
~~~~~~~~~~~~~~~~
77+
Perform a query
78+
~~~~~~~~~~~~~~~
7979

8080
.. code:: python
8181
8282
from google.cloud import bigquery
83-
from google.cloud.bigquery import Dataset
8483
8584
client = bigquery.Client()
8685
87-
dataset_ref = client.dataset('dataset_name')
88-
dataset = Dataset(dataset_ref)
89-
dataset.description = 'my dataset'
90-
dataset = client.create_dataset(dataset) # API request
91-
92-
Load data from CSV
93-
~~~~~~~~~~~~~~~~~~
94-
95-
.. code:: python
96-
97-
import csv
98-
99-
from google.cloud import bigquery
100-
from google.cloud.bigquery import LoadJobConfig
101-
from google.cloud.bigquery import SchemaField
102-
103-
client = bigquery.Client()
104-
105-
SCHEMA = [
106-
SchemaField('full_name', 'STRING', mode='required'),
107-
SchemaField('age', 'INTEGER', mode='required'),
108-
]
109-
table_ref = client.dataset('dataset_name').table('table_name')
110-
111-
load_config = LoadJobConfig()
112-
load_config.skip_leading_rows = 1
113-
load_config.schema = SCHEMA
114-
115-
# Contents of csv_file.csv:
116-
# Name,Age
117-
# Tim,99
118-
with open('csv_file.csv', 'rb') as readable:
119-
client.load_table_from_file(
120-
readable, table_ref, job_config=load_config) # API request
121-
122-
Perform a query
123-
~~~~~~~~~~~~~~~
124-
125-
.. code:: python
126-
12786
# Perform a query.
12887
QUERY = (
12988
'SELECT name FROM `bigquery-public-data.usa_names.usa_1910_2013` '

0 commit comments

Comments
 (0)