google appscript to write sheet data to fusion table

109 Views Asked by At

Would someone have examples of a current Sheet Script (JScript) that authenticates and performs read/write between matching tables in Google Sheet and Fusion? Online sample scripts and documentation all use old authentication or other APIs. I'm helping out a local non-profit with a Mapping application that will read data from Google Fusion. The data entry UI is in Google Sheet, so I need to move new records to Fusion, and read Reference tables values from Fusion to Sheet.

  • I can't get past setting up authentication. New to this altogether.
  • With a variety of field datatypes, and lot's of text fields, I'm sure I need to wrap the field data somehow, unless there is a painless method.

Thanks in advance. Eric

1

There are 1 best solutions below

1
On BEST ANSWER

Actually you don't need OAuth for a pure GAS FusionTables project. All you need is to add the API library, and enable it in the Developer's Console.

You can then execute simple SQL Statements like this:

FusionTables.Query.sql("INSERT INTO tblId ('fld1', 'fld2') VALUES('x', 'y')")

and

var vQueryResult = FusionTables.Query.sql("SELECT * FROM tblId WHERE 'fld1'='xyz'");

If you know SQL, you will find yourself frustrated by missing basics such as the OR statement, but with a little ingenuity (and using Google's servers to crunch lookup lists in code), you can get most things done.