bigquery.table¶
Classes¶
Module Contents¶
- class bigquery.table.Table(dataset_name, table_name, project=None, service_file=None, session=None, token=None, api_root=None)¶
Bases:
bigquery.bigquery.BigqueryBase
- Parameters:
dataset_name (str)
table_name (str)
project (Optional[str])
service_file (Optional[Union[str, IO[AnyStr]]])
session (Optional[requests.Session])
token (Optional[gcloud.aio.auth.Token])
api_root (Optional[str])
- dataset_name¶
- table_name¶
- static _mk_unique_insert_id(row)¶
- Parameters:
row (Dict[str, Any])
- Return type:
str
- _make_copy_body(source_project, destination_project, destination_dataset, destination_table)¶
- Parameters:
source_project (str)
destination_project (str)
destination_dataset (str)
destination_table (str)
- Return type:
Dict[str, Any]
- static _make_insert_body(rows, *, skip_invalid, ignore_unknown, template_suffix, insert_id_fn)¶
- Parameters:
rows (List[Dict[str, Any]])
skip_invalid (bool)
ignore_unknown (bool)
template_suffix (Optional[str])
insert_id_fn (Callable[[Dict[str, Any]], str])
- Return type:
Dict[str, Any]
- _make_load_body(source_uris, project, autodetect, source_format, write_disposition, ignore_unknown_values, schema_update_options)¶
- Parameters:
source_uris (List[str])
project (str)
autodetect (bool)
source_format (bigquery.bigquery.SourceFormat)
write_disposition (bigquery.bigquery.Disposition)
ignore_unknown_values (bool)
schema_update_options (List[bigquery.bigquery.SchemaUpdateOption])
- Return type:
Dict[str, Any]
- _make_query_body(query, project, write_disposition, use_query_cache, dry_run)¶
- Parameters:
query (str)
project (str)
write_disposition (bigquery.bigquery.Disposition)
use_query_cache (bool)
dry_run (bool)
- Return type:
Dict[str, Any]
- async create(table, session=None, timeout=60)¶
Create the table specified by tableId from the dataset.
- Parameters:
table (Dict[str, Any])
session (Optional[requests.Session])
timeout (int)
- Return type:
Dict[str, Any]
- async patch(table, session=None, timeout=60)¶
Patch an existing table specified by tableId from the dataset.
- Parameters:
table (Dict[str, Any])
session (Optional[requests.Session])
timeout (int)
- Return type:
Dict[str, Any]
- async delete(session=None, timeout=60)¶
Deletes the table specified by tableId from the dataset.
- Parameters:
session (Optional[requests.Session])
timeout (int)
- Return type:
Dict[str, Any]
- async get(session=None, timeout=60)¶
Gets the specified table resource by table ID.
- Parameters:
session (Optional[requests.Session])
timeout (int)
- Return type:
Dict[str, Any]
- async insert(rows, skip_invalid=False, ignore_unknown=True, session=None, template_suffix=None, timeout=60, *, insert_id_fn=None)¶
Streams data into BigQuery
By default, each row is assigned a unique insertId. This can be customized by supplying an insert_id_fn which takes a row and returns an insertId.
In cases where at least one row has successfully been inserted and at least one row has failed to be inserted, the Google API will return a 2xx (successful) response along with an insertErrors key in the response JSON containing details on the failing rows.
- Parameters:
rows (List[Dict[str, Any]])
skip_invalid (bool)
ignore_unknown (bool)
session (Optional[requests.Session])
template_suffix (Optional[str])
timeout (int)
insert_id_fn (Optional[Callable[[Dict[str, Any]], str]])
- Return type:
Dict[str, Any]
- async insert_via_copy(destination_project, destination_dataset, destination_table, session=None, timeout=60)¶
Copy BQ table to another table in BQ
- Parameters:
destination_project (str)
destination_dataset (str)
destination_table (str)
session (Optional[requests.Session])
timeout (int)
- Return type:
- async insert_via_load(source_uris, session=None, autodetect=False, source_format=SourceFormat.CSV, write_disposition=Disposition.WRITE_TRUNCATE, timeout=60, ignore_unknown_values=False, schema_update_options=None)¶
Loads entities from storage to BigQuery.
- Parameters:
source_uris (List[str])
session (Optional[requests.Session])
autodetect (bool)
source_format (bigquery.bigquery.SourceFormat)
write_disposition (bigquery.bigquery.Disposition)
timeout (int)
ignore_unknown_values (bool)
schema_update_options (Optional[List[bigquery.bigquery.SchemaUpdateOption]])
- Return type:
- async insert_via_query(query, session=None, write_disposition=Disposition.WRITE_EMPTY, timeout=60, use_query_cache=True, dry_run=False)¶
Create table as a result of the query
- Parameters:
query (str)
session (Optional[requests.Session])
write_disposition (bigquery.bigquery.Disposition)
timeout (int)
use_query_cache (bool)
dry_run (bool)
- Return type:
- async list_tabledata(session=None, timeout=60, params=None)¶
List the content of a table in rows.
- Parameters:
session (Optional[requests.Session])
timeout (int)
params (Optional[Dict[str, Any]])
- Return type:
Dict[str, Any]