Reputation: 63
I'm trying to import my pandas dataframe to BigQuery, but always that I try the code insert more rows when I want to overwrite it.
client = bigquery.Client()
table_id = 'getdata-345817.get_data.fbinsights'
write_disposition = 'WRITE_TRUNCATE'
job = client.load_table_from_dataframe(
df, table_id
)
job.result()
table = client.get_table(table_id)
print(
"Loaded {} rows and {} columns to {}".format(
table.num_rows, len(table.schema), table_id
)
)
I've tried "write_truncate" but can't solve it.
Upvotes: 3
Views: 988
Reputation: 63
I've resolved inserting:
job_config = bigquery.LoadJobConfig(
write_disposition=bigquery.job.WriteDisposition.WRITE_TRUNCATE
)
I hope this solution help other programmers with the same issue.
Upvotes: 3