Since BigQuery has already been integrated to Google Spreadsheet,
here's what you have to do with your Script:
1. Send HTTP request using Datasets: update with added path parameters datasetId and projectId.
Sample HTTP request:
PUT https://www.googleapis.com/bigquery/v2/projects/projectId/datasets/datasetId
However, please note of the following when using Datasets: update:
- It requires authorization as stated in Authenticating requests to the Google BigQuery API
- The specified access list completely overwrites the existing access list. If you specify an empty access list, you will revoke access to everyone except yourself
- This request requires authorization with at least one of the following scopes:
Scope
https://www.googleapis.com/auth/bigquery
https://www.googleapis.com/auth/cloud-platform
2. To update your data automatically, you can set up a Trigger function from inside your Script which executes based on your preferences with these reserved function names:
onOpen(e) runs when a user opens a spreadsheet, document, or form that he or she has permission to edit.
onEdit(e) runs when a user changes a value in a spreadsheet.
onInstall(e) runs when a user installs an add-on.
doGet(e) runs when a user visits a web app or a program sends an HTTP GET request to a web app.
doPost(e) runs when a program sends an HTTP POST request to a web app.
Again, you should also note that because simple triggers fire automatically, they are subject to several restrictions which you can go through in the documentation.