Batch insert google apps script
<p>Batch insertion in google apps script. I am using push to write data from a table to a sheet. Is there a way to do batch insert 3000 records and loop through via a trigger to execute after a couple of minutes until all the records are inserted in google apps script.</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>  function myBatchInsert() {
    var connection = Jdbc.getConnection("jdbc:mysql://host:port", "user", "passwrd");
    var query = connection.createStatement();
    var result = query.executeQuery('SELECT * FROM Table WHERE');
    var googlespreadsheet;
    var sheet;
    var googlespreadsheetSheetName = "Table";

    googlespreadsheet = SpreadsheetApp.openById(SpreadsheetApp.getActiveSpreadsheet().getId());

    var datasheet = googlespreadsheet.getSheetByName("Table");
    datasheet.setName("Table");

    SpreadsheetApp.setActiveSpreadsheet(googlespreadsheet);
    sheet = SpreadsheetApp.setActiveSheet(googlespreadsheet.getSheetByName(googlespreadsheetSheetName));

    var columncount = result.getMetaData().getColumnCount();
    var columnName;

    for (var column = 1; column &lt;= columncount; column++) {
      sheet.getRange(1, column).setValue(result.getMetaData().getColumnName(column));
    }

    var document = SpreadsheetApp.getActiveSpreadsheet();
    var cell = document.getRange('A2');
    var row = 0;
    var data = [];

    for (var i = 0; i &lt; 1; i++) {
      while (result.next()) {
        var rowData = [];
        for (var column = 0; column &lt; result.getMetaData().getColumnCount(); column++) {
          rowData.push(result.getString(column + 1));
        }
        data.push(rowData);
      }

      sheet.getRange(sheet.getLastRow() + 1, 1, data.length, data[0].length).setValues(data);
    }

    result.close();
    query.close();
    connection.close();
  }</code></pre>
</div>
</div>
</p>