from google.cloud import bigquery
from google.oauth2 import service_account
location = 'australia-southeast1'
project = 'project123'
client = bigquery.Client(project=project, location=location)
def upload_df_to_BQ(df, table_name, mode='append'):
project_id = table_name.split('.')[0]
table_name = table_name.split('.', 1)[1]
logger.debug(f"Uploading to BigQuery {table_name}. Persistent staging = {mode}")
df.to_gbq(table_name, location=location, if_exists=mode)
logger.debug(f"Uploaded to BigQuery {table_name}. Persistent staging = {mode}")
upload_df_to_BQ(my_dataframe, 'TEST_TABLE')
Last active
May 6, 2020 08:39
-
-
Save alcheng10/f7e626d104a1d3545946e0a744fe8094 to your computer and use it in GitHub Desktop.
GCP BigQuery SDK Example
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment