Connect Google Drive to Could SQL - google-drive-api

I am looking to try and combine Google's Cloud SQL service with google drive. Essentially I want to use Google forms for the user to easily input data, and then have that data feed into the Cloud SQL environment (from which I can do reporting and analysis).
My question is, has anyone done this already, or have any ideas of how this might be accomplished? I already have google forms writing to spreadsheets, and that works fine. I am familiar with SQL so creating reports and pulling data from the Cloud SQL environment shouldn't be hard.....but I don't know how to connect the two.
Ideally I would like something to run on a schedule (maybe on a nightly basis) to pull the data from a google spreadsheet, update the Cloud SQL database, and clear the old data from the spreadsheet.

I think the best way to do this would be to use Google Apps Script.
Apps Script allows you, for a given form, to define an onSubmit() method that will be called when someone submitted an answer to the form.
Then you can use the JDBC service to connect to Cloud SQL.

Related

insert MySQL from Google sheet

I need to insert a Google spreadsheet information into a MySQL table database automatically every 2 h. Can someone help me, please?
I have already used import tool in phpMyAdmin, but manually, and I need to do it automatically.
Maybe it can be with importmysql or load data infile script. But I need some guidelines, I'm not a programmer, however I can learn the basics to implement it.
Based from this forum: Google Apps Script to Export Spreadsheets to mySQL execute on multiple files:
If your MySQL instance is a public-facing instance, accessible from outside your local network, you could use Google Apps Script JDBC Service to connect to your MySQL instance and insert/update data from your google sheets. Please read the Setup for other databases section of JDBC guide for details on setting up your database for connection from Google Apps Script.
You can have one script that loops through all spreadsheets in a given folder and inserts data from each into your MySQL database.

How to access BigQuery generally from Google Apps Script

I have a Google Apps Script application that currently accesses a GCP SQL database with JDBC.
Using the normal SQL database doesn't cut it, so I decided to try BigQuery.
Is there a way to access BigQuery from Google Apps Script without connecting with an account connected to the GCP project? I want guests who use my script to be able to get data.
I'm looking for either a general way (as in: IP, database, username, password and I manage the connection) or a client library way I can use with Apps Script.
Note, the BigQuery Apps Script plugin seem to only allow access to my own databases, so guests will get denied access.
As per this link , you can share your BigQuery dataset with specific users even if they're not part of the GCP project. Since they need to be able to retrieve data, they will need "Viewer" permission on the dataset. The steps to do this are described in here and this link will show you with an example how you can query your BigQuery table from Apps Script.

How to receive emailed csv data into Google Cloud SQL

The goal is to set up a simple relational database in Google Cloud SQL (or BigQuery) that automatically receives/retrieves daily emailed reports. The data source, in this case, is Doubleclick but regardless of the source, I'd like to better understand how scheduled email reports (as attachments) can be sent to or ingested by Google Cloud SQL.
Is there some other app or service out there to make this connection? Is there a Google product like MS Visual Studio to run jobs? Sorry for the very beginner questions but none of the Google support articles are very helpful!
You will need to use Google Apps Scripts to tie the process together.
App Scripts can DoubleClick data and potentially read from a gmail account.
Once you have access to the data, you should be able to use BigQuery service in script to load the data
You can then create a scheduled project trigger within script to poll periodically for new files

Google Form output to remote MySQL database

I have a Google Form I created. I have a website with a remote MySQL database. I would like to embed the Google Form into my site (this I've figured out), however instead of the data from form submission being stored in a Google Spreadsheet(s), I'd like the data to be sent to my MySQL database, to a predefined table designed to accept the data types being collected and validated for in the Google Form.
I have researched and come across Google Apps Scripts (https://developers.google.com/apps-script/guides/jdbc). My issue is that I'm not experienced with Google Apps Scripts and am seeking guidance in setting this up. I have the Google Form, access to a my Google Apps account, and the connection string to my remote MySQL database with administrator privileges. I'm seeking guidance, step-by-step as I have not found any tutorials online yet. If you can guide me to a tutorial, that would be appreciated as well.
Recently you can use a database in Google app script.
App script support ( Google Cloud SQL, MySQL, Microsoft SQL Server, and Oracle databases ) with JDBC Class
DOcumentation : https://developers.google.com/apps-script/guides/jdbc
You can add script in Google From.
It's possible to create a form that does not send responses to a linked spreadsheet. In the "RESPONSE" menu, choose "CHOOSE RESPONSE DESTINATION". You can create an installable 'Form Submit' trigger to run some code. In the code editor, choose RESOURCES, CURRENT PROJECT TRIGGERS, add a trigger, and set it to run when the form is submitted. Then you'll need to use get item responses:
Google documentation - Forms
Bruce McPherson offers some step-by-step guides on his site if you use his cDbAbstraction library to access any external DBs.
If you don't want to roll your own solution to this, check out the Form integration in SeekWell. You just write a SQL snippet and can map fields in the Form to parameters in the SQL.
Disclaimer: I made this.

Sync data from Google spreadsheet to Cloud SQL using Google Apps Script

I am creating an application where I will be inserting spreadsheet data to Cloud SQL using jdbc service. I would like to know answers of following :
Q1. What will happen if the insert statement is executing and someone closes the spreadsheet/script?
Q2. is there any possibility of inserting the data to Cloud SQL using Google Apps script in offline mode?
The answer to both questions is actually a similar one - since both Cloud SQL and Apps Script are entirely always online cloud systems - it doesn't matter if the file is closed or if a user goes offline. The script should run to completion.