File size: 1,807 Bytes
065fee7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
Running Queries
~~~~~~~~~~~~~~~
Querying data
^^^^^^^^^^^^^
Run a query and wait for it to finish with the
:func:`~google.cloud.bigquery.client.Client.query_and_wait` method:
.. literalinclude:: ../samples/snippets/client_query.py
:language: python
:dedent: 4
:start-after: [START bigquery_query]
:end-before: [END bigquery_query]
Run a dry run query
^^^^^^^^^^^^^^^^^^^
.. literalinclude:: ../samples/client_query_dry_run.py
:language: python
:dedent: 4
:start-after: [START bigquery_query_dry_run]
:end-before: [END bigquery_query_dry_run]
Writing query results to a destination table
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
See BigQuery documentation for more information on
`writing query results <https://cloud.google.com/bigquery/docs/writing-results>`_.
.. literalinclude:: ../samples/client_query_destination_table.py
:language: python
:dedent: 4
:start-after: [START bigquery_query_destination_table]
:end-before: [END bigquery_query_destination_table]
Run a query using a named query parameter
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
See BigQuery documentation for more information on
`parameterized queries <https://cloud.google.com/bigquery/docs/parameterized-queries>`_.
.. literalinclude:: ../samples/client_query_w_named_params.py
:language: python
:dedent: 4
:start-after: [START bigquery_query_params_named]
:end-before: [END bigquery_query_params_named]
Run a script
^^^^^^^^^^^^
See BigQuery documentation for more information on `scripting in BigQuery
standard SQL
<https://cloud.google.com/bigquery/docs/reference/standard-sql/scripting>`_.
.. literalinclude:: ../samples/query_script.py
:language: python
:dedent: 4
:start-after: [START bigquery_query_script]
:end-before: [END bigquery_query_script]
|