in hacks/genai-intro/artifacts/function/main.py [0:0]
def store_results_in_bq(dataset: str, table: str, columns: dict[str, str]) -> bool:
"""Stores the results of title extraction and summary generation in BigQuery.
Do not edit.
Args:
dataset: the name of the BigQuery dataset
table: the name of the BigQuery table where the results will be stored
columns: a dictionary of columns and their values
Returns:
True if successful, False otherwise (if there were any errors)
"""
client = bigquery.Client(project=PROJECT_ID)
table_uri = f"{dataset}.{table}"
rows_to_insert = [columns]
errors = client.insert_rows_json(
table_uri, rows_to_insert, row_ids=bigquery.AutoRowIDs.GENERATE_UUID
)
if errors:
print("Errors while storing data in BQ:", errors)
return not errors