Skip to content

Commit

Permalink
add examples (#952)
Browse files Browse the repository at this point in the history
  • Loading branch information
IanRFerguson authored Dec 8, 2023
1 parent 41cd255 commit 5e528d6
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions docs/google.rst
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ We can now upload/query data.
# Table name should be project.dataset.table, or dataset.table, if
# working with the default project
table_name = project + '.' + dataset + '.' + table
table_name = f"`{project}.{dataset}.{table}`"
# Must be pre-existing bucket. Create via GoogleCloudStorage() or
# at https://console.cloud.google.com/storage/create-bucket. May be
Expand All @@ -117,13 +117,21 @@ We can now upload/query data.
{'name':'Bill', 'party':'I'}])
# Copy table in to create new BigQuery table
bigquery.copy(table_obj=parsons_table,
table_name=table_name,
tmp_gcs_bucket=gcs_temp_bucket)
bigquery.copy(
table_obj=parsons_table,
table_name=table_name,
tmp_gcs_bucket=gcs_temp_bucket
)
# Select from project.dataset.table
bigquery.query(f'select name from {table_name} where party = "D"')
# Query with parameters
bigquery.query(
f"select name from {table_name} where party = %s",
parameters=["D"]
)
# Delete the table when we're done
bigquery.client.delete_table(table=table_name)
Expand Down

0 comments on commit 5e528d6

Please sign in to comment.