Database Reference
In-Depth Information
bigquery/client-libraries has a number of links to these
auto-generated client libraries for languages from Java to PHP to Ruby. The
Python library, in particular, is used in many of the samples in this topic. For
the most part, you should use the client libraries instead of coding directly
against the API. It will be easier, it will be type-safe (in languages that are
statically typed), and it will let you know in the event that some behavior in
the API changes.
There is, however, a downside to an automatically generated client: The
code that gets generated might not be the code that you'd write if you were
writing a client from scratch. Some operations may be awkward; others
may not use language features as cleanly as you'd like. For example, in
the Java client, the JobStatus.getState() method returns a String ,
when it would be cleaner to return an enum containing the possible values.
That said, the generated client is often convenient, especially when using a
modern code editor that can autocomplete or display documentation.
From Python, to use the automatically generated BigQuery client, just
import apiclient.discovery and call build() :
>>>f rom apiclient.discovery import build
>>> service = build('bigquery', 'v2')
You can then use the generated client to call BigQuery:
>>> service.projects().list().execute()
{u'totalItems': 3, u'kind': u'bigquery#projectList', …}
Common Operations
Several operations are common across the BigQuery collections and are
generally common across other Google APIs as well. This section describes
a number of them as they apply to BigQuery and demonstrates their usage
with bq.py and curl .
Paging through Collections
Often there are more results in a collection than are convenient to return
at a single time. When this is true, the results will be truncated—you'll get
only the first page of results. If you have run 10,000 jobs, you may only care
about the most recent ones, so you might be okay with just these limited
Search WWH ::




Custom Search