Thursday, November 15, 2012

Re: Google Apps Script JDBC Service and Google Cloud SQL

Hi Sarathbabou

The Apps Script Range class includes a getValues() method for getting the values out of a spreadsheet. See

For example, this will get the values for the range A1:B10 in the active spreadsheet. 

var values = SpreadsheetApp.getActiveSheet().getRange(0, 0, 10, 1).getValues();

You can then create a connection to a Cloud SQL database and insert the values. See https://developers.google.com/apps-script/jdbc

var conn = Jdbc.getCloudSqlConnection("jdbc:google:rdbms://instance_name/database_name");
conn.setAutoCommit(false);
var stmt = conn.prepareStatement("insert into person (lname,fname) values (?,?)");
for (var i = 0; i < 10; i++) {
    // Objects are accessed using 1-based indexing
    stmt.setObject(1, var[i][0]);
    stmt.setObject(2, var[i][1]);
    stmt.addBatch();
}
var res = stmt.executeBatch();
conn.commit();
conn.close();


On Thu, Nov 15, 2012 at 9:22 AM, SS <sarathbabou.somaya@ssomens.com> wrote:
Sorry Joe,
                       Bt then using JDBC, how will u import the Data directly into GC SQL from the Spreadsheet Data?
Sorry I m a bit lost!

Hw to get the values from the SpreadSheet using JDBC?
I want all my Spreadsheet data to be migrated to GC SQL?

Thnks fr ur help!

--Som


On Saturday, November 10, 2012 10:53:23 PM UTC+8, Joe Faith wrote:

Hi Son

You could use an Apps Script to gather the data from your spreadsheet then use the new JDBC to insert the values into your Cloud SQL database.

Joe Faith | Google Cloud Product Manager
Sent from my phone, so please excuse my brevity.

On Nov 10, 2012 2:05 AM, "SS" <sarathbab...@ssomens.com> wrote:
Hi Joe,
           Any direct tool/method/function to import DATA from ScriptDB/Spreadsheet into Google Cloud SQL?

If so, plz refer me to the lnk!

1000 Thnks,
Som

On Saturday, November 10, 2012 12:54:41 AM UTC+8, Joe Faith wrote:
I'm very pleased to say that Apps Script now has a JDBC to Cloud SQL

Hope you can make good use of it, and let us know how you get on.

j

On Thu, Nov 1, 2012 at 12:12 AM, DaBe <rup...@kromco.co.za> wrote:
For what it's worth. Agreed, we need the direct CLoudSQL connectivity from Google Spreadsheet Query and Apps Script.



--
Joe Faith | Product Manager | Google Cloud



--
Joe Faith | Product Manager | Google Cloud

No comments:

Post a Comment