Google Fusion Tables

Create a Fusion Table

function createFusionTable() {
  var table = FusionTables.newTable();
  table.name = 'My sales table';
  table.columns = [
    createColumn('Product', 'STRING'),
    createColumn('Date', 'DATETIME'),
    createColumn('Sales', 'NUMBER')
  ];
  table.isExportable = true;
  var newTable = FusionTables.Table.insert(table);

  Logger.log('Table with ID = %s and name = %s was created.',
             newTable.tableId, newTable.name);
}

Insert data into a Fusion Table

function insertDataIntoFusionTable() {
  // See https://developers.google.com/chart/interactive/docs/fusiontables for
  // details on how to obtain your Google Fusion Table's ID from its URL.

  var tableId = 'INSERT_FUSION_TABLE_ID_HERE';

  // Prepare the data to insert into the table. This should be in CSV format,
  // and should match your table's schema.
  var data = Utilities.newBlob('Cake,2014-01-01,25\nCake,2014-01-02,35\n');
  data.setContentType('application/octet-stream');
  FusionTables.Table.importRows(tableId, data);

  Logger.log('Data imported successfully into Fusion Table.');
}

Query data from Fusion Table

function queryDataFromFusionTable() {
  // See https://developers.google.com/chart/interactive/docs/fusiontables for
  // details on how to obtain your Google Fusion Table's ID from its URL.

  var tableId = 'INSERT_FUSION_TABLE_ID_HERE';

  var results = FusionTables.Query.sql('Select Date, Sales from ' + tableId +
      " where Product = 'Cake'");

  Logger.log(results.columns.join(','));
  for (var i = 0; i < results.rows.length; i++) {
    Logger.log(results.rows[i].join(','));
  }
}

发送以下问题的反馈:

此网页
AdWords Scripts
AdWords Scripts
需要帮助?请访问我们的支持页面