I am currently trying to pull the following into google sheets via a very simple script.
The view is about 16k rows and A-W in width. This code executes and in MySQL in about 1 second. When trying to run the code as a script it is timing out at more than 1800 seconds.
Does anyone know how to get the data to populate faster into sheets?
Code
var query = "";
query += ' SELECT '
+' * '
+' FROM rep_fin_sml_dash_es'
var result = statement.executeQuery(query);
var num_col = result.getMetaData().getColumnCount();
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName("Supply Data");
sheet.getRange('A2:W').clearContent();
var header = ['Accommodation Provider'];
for(var h = 1; h < header.length; h++ ){
sheet.getRange(1, h+1).setValue(header[h]);
}
var cell = sheet.getRange('A2');
var row = 0;
while(result.next()) {
for(var i=0; i < num_col; i++) {
cell.offset(row, i).setValue(result.getString(i+1));
}
row++;
}
//tidy up
result.close();
statement.close();
connection.close();
}