chris lockhart
Automatically refresh BigQuery connections in Google Sheets
August 28, 2020

Ever want to automate BigQuery pulls into Google Sheets? Well, script.google.com has you covered.

Create a project and then dump in the following 3 short lines. Note you'll have to update spreadsheetId.

var spreadsheet = SpreadsheetApp.openById(spreadsheetId);
SpreadsheetApp.enableAllDataSourcesExecution();
spreadsheet.getDataSourceTables()[0].refreshData();


That's all there is to it! Then, you can schedule it with Google Apps Script triggers.