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.
Related
I'm creating forms on demand and i need to be able to set up the triggers. If i do it on the main AppsScript script that is handling the forms creation, i'll hit the 20 triggers max quota pretty soon. So i decided to add a dedicated script to every form (associating with parentID) so i won't hit the quota.
My problem is that when i try to add the triggers i'm getting permission denied since the scripts created for each form are using a default GCP project and it needs to be a standard GCP project due to OAuth.
I can add the project number manually, but that kind of defeats the idea of being able to generate google forms on demand.
I want to be able to link the script created with the standard GCP project that is already configured, but i just can't find anything on Google's documentation, i know its a long shot but i've decided to post here in hopes that someone that had the same problem managed to do so.
As requested on the comments below, the triggers that i'm using are:
onFormSubmit - get the response and send it to my endpoint in the backend server
onOpen - ensures that the editor hasn't removed anything default (this only works when an editor opens the form in edit mode)
This is the project number im referring to.
Thanks
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
I want to set up scripts in sheets creating several menu options for predefined queries. This way normal bob can get his queries, Tina can get hers, and Fredrick in accounting can get the information he needs without out writing his own queries. They can use a fun menu:
screenshot
The data table is set up in BigQuery, and queries work fine using the 'compose query' option. The issue is getting queries written in the script to function in sheets. Here is a nice tutorial by Ido Green on how to go about it. https://greenido.wordpress.com/2013/12/16/big-query-and-google-spreadsheet-intergration/
My problem is getting the permissions to work. I believe I approved the project ID in BigQuery, but I am unsure of how to do this in Drive. This is new to me. Let me know if someone has the step by step. This is the error I get when I try to run the script:
"Exception: No suitable credentials found to access Google Drive. Contact the table owner for assistance."
Thank you for your help
Got the same issue with my Google Apps script.
Steps to fix
Enable Google Drive API in Resources -> Advanced Google Services
Enable Google Drive API in Google Developers Console for this project
Run 'DriveApp.getRootFolder();' to get Drive Auth Scope .
I think the problem is in the OAuth Scopes.
According to this SO question, If you are using the BigQuery web UI and have not explicitly granted access to Drive, it won't work. For example, the first time I tried to "Save to Google Sheets", the BigQuery UI popped up an OAuth prompt asking me to grant access to my Google Drive. After this it could save the results. Try doing this to make sure your credentials have the Drive scope and then "Save View" again.
If you are using your own code to do this, you should request scope 'https://www.googleapis.com/auth/drive' in addition to the 'https://www.googleapis.com/auth/bigquery' scope you are already using to talk to BigQuery.
Also check this SO question and this community page for more information.
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.
I have a Google Apps script (written in a Google Spreadsheet) that creates a separate calendar and events for it with respect to a university course and the university calendar. The GUI is a Spreadsheet form, which triggers the execution of my script. The script gets its input from the spreadsheet form entry.
The trouble I have is that I can't easily deploy my solution to other users. Yes, they can make a copy of my sheet/form/scripts, so that they can run it on their account. Several problems, however, result from this approach:
triggers don't get copied - this is because authorization to access local info (calendars, contacts, etc.) must be given by the users before a trigger is enabled. So users have to re-connect the form submission trigger to the Apps Script for it to work (this is not user friendly).
if I change the code of my apps script, the users are using a copy and won't see the changes.
The solution seems to be Google Web Apps, but from what I've read, I can't re-use the form-based GUI of my approach. Or can I?
Google Spreadsheet Forms have the advantage that they are very easy to create, and you can already specify what fields are mandatory, etc. I don't want to have to re-write all of this in a complicated GUI front-end to my Google Apps Script (Edit: even the GUI builder tool seems way more complicated than a Spreadsheet Form), yet I want other users to be able to create the calendars and events in their own Google accounts. Is there a way to keep my form, but have it hooked to a Web App version of my code?
Try adding the form on a google sites (intranet). This way, any user having access, will be able to use the form as it is. All logic you created will remain the same.
Creating a script however will allow the user to execute the script "under their login", thus enabling access to calendars, contacts......