选择一个表中的特定行,并使用google-apps-script插入其他表

时间:2017-09-25 06:14:24

标签: mysql google-apps-script

表名:在test_tbl中选择item = mobile,并使用google-apps-script(google execl sheet)插入其他表名为other_tbl。

enter image description here

代码:

function readFromTable() {
  var conn = Jdbc.getConnection(dbUrl, user, userPwd);

  var start = new Date();
  var stmt = conn.createStatement();
  stmt.setMaxRows(100);
  var results = stmt.executeQuery('SELECT * FROM test_table where Price ="100"');
  var numCols = results.getMetaData().getColumnCount();

  while (results.next()) {
    var rowString = '';
    for (var col = 0; col < numCols; col++) {
      rowString += results.getString(col + 1) + '\t';        
      var cell_4 = rowString ;
    }    
    Logger.log(rowString)
  }

  results.close();
  stmt.close();

  var end = new Date();
  Logger.log('Time elapsed: %sms', end - start);
}

0 个答案:

没有答案