# Google Sheets and MySQL integration – Powerful workflow

## Метаданные

- **Канал:** n8n
- **YouTube:** https://www.youtube.com/watch?v=cve5U-RCpHs
- **Дата:** 09.11.2023
- **Длительность:** 10:25
- **Просмотры:** 17,300
- **Источник:** https://ekstraktznaniy.ru/video/15690

## Описание

In this video, we connect Google Sheets and MySQL into a powerful workflow that integrates Google Sheets and MySQL by comparing datasets, updating records, and syncing data based on specified conditions, triggered by manual execution and scheduled intervals.

Get the workflow template for free:
https://bit.ly/3SA6sQf

More workflows and documentation for Google Sheets and MySQL integration:
https://bit.ly/3QzVXtF 

About n8n
n8n is a source-available workflow automation tool designed for technical users, and with over 300 pre-built integrations and a general connector for anything with an API, n8n enables you to connect anything to everything. With n8n you can move beyond simple one step integrations to build multi-step workflows that integrate your tools exactly the way you want. Thanks to its fair-code distribution model, n8n will always have visible source code, be available to self-host, is free to use.

Get n8n for free: https://bit.ly/3MADgom 

Join the community forum and ask yo

## Транскрипт

### Introduction []

hello and welcome back to this step-by-step tutorial today we are going to create a Google sheet in my SQL integration using na a source available workflow automation tool take a look at the example workflow when a user fills out a Google form new entry is added to the Google spreadsheet next we will add these Google sheet rows into a centralized SQL database using n you can create a simple automation just for this purpose each published NN template can

### Template [0:36]

be copy pasted directly into the editor you will find the link to the template for this tutorial in the description below the video you can pause the video and come back to it when you're ready to continue you will need a couple of extra things to complete this tutorial a Google Cloud platform project a running

### Prerequisites [0:54]

my SQL database don't worry we will explain how to create the them in just a few seconds so let's get

### Create workflow [1:03]

started first open n in your web browser and add a new workflow in this tutorial we will create a Google sheet in my SQL integration from scratch for now select the manual trigger we will add the schedule trigger later now let's add our first data source the Google sheet node create new credentials if you have never

### Create credentials [1:24]

created oo2 credentials for Google before go to the open docs link and follow the instructions create a new Google Cloud platform project configure an O off consent screen once for the new project add new credentials next register the ooth redirect URL from n8n in Google Cloud take the client ID and a client secret paste these into the corresponding n8n Fields now sign in with Google Grant access and press continue all set to load data but wait a second we don't have data yet let's fix that too create

### Create a Google Form [2:18]

a new Google form with several questions you can take the question names from the workflow page make sure that the Google form answers are saved in a separate spreadsheet click on The View and sheets button and add a new variable DB status it will show which entries were synchronized in my SQL database now let's test this first data source make a few form submissions copy the spreadsheet URL come back to n8n enter this URL

### Test the first data source [2:59]

into the document field and configure the node as shown on the screen don't forget to click on the add option button and select return all matches click the execute node button great your first data source is ready

### Create a MySQL database [3:20]

before moving on we also need to create a mySQL database if you don't have one just visit a DB for free website sign up for a new database and fill in the text Fields after that you will receive a confirmation email click on the link to activate the new database now you can log into the new database through PHP my admin create a new table where we will store the Google sheet records click on the database name on the left then click on the import button we will load an SQL file that creates a new table for us you can get a link to this file from the workflow page on the NN website create a new table has been added let's connect this mySQL database to NN to do this

### Connect MySQL to NN [4:04]

create new credentials and fill in the fields according to the activation email now let's switch the operation mode to select and pick a new table from the drop-down list configure the node as shown on the screen after connecting the two data

### Configure NN [4:19]

sources let's run the workflow again the variable names from Google sheet are different from my SQL table let's add a set node and rename name the variables as shown on the screen enter this JS snippet to convert Google timestamp into a valid ISO date also don't forget to click on the keep only set switch now let's

### Sync data [4:58]

synchronize the data add a compare data sets node enter fields to match in the config window timestamp and Source name we also want to ignore some my SQL service variables add them into the fields to skip comparing now close the configuration screen connect the set node to input a connect the MySQL node to input B and run the workflow as you can see an a only Branch contains new Google sheet items that have not yet been integrated let's drag a line from this output and add a new MySQL node in the config window select the same credentials make sure that operation is set to insert or update and configure the node as demonstrated if everything is done correctly several new rows will appear in my SQL database before we go any further please make sure to hit the like button subscribe to the channel and turn on notific ifications for all future videos we regularly release new content so stay tuned our integration has a couple of limitations as of now imagine there are more and more data in Google sheet as users submit new forms for now n8n will load all items every time the workflow starts thus slowing down this integration over time let's fix that

### Fix DB status [6:21]

first let's assume that submitted forms are reviewed and either accepted or rejected go into PHP my admin and change the DV stat status of one R into my SQL database let's go back to the n8n canvas and run the workflow again this time the compare data sets node shows an item in the different branch output we can see that the initial status from Google Sheets is empty but there is some value in the my SQL database let's connect an if node to this output and make sure that only status changes in the database are taken into account finally add a new Google sheet node select the update operation and configure the node as demonstrated the Google sheet document now has a value for the DB status now

### Limit DB items [7:19]

let's limit the number of items coming from my SQL database run the workflow again as you can see items still come from the database this time one of them goes into the NB only Branch since there is no correspondent item in the input a let's add a similar if node and make sure that Source name is not empty after that let's add another MySQL node select update operation and a table specify colum to match on and update only the source name column now we have marked the record as synced and we are no longer taking it from the database let's take it one step further and automate the notifications for the unanswered

### Automate notifications [8:20]

unanswered forms as you can see items with missing DB status go into same Branch output we can consider such records as unanswered form submissions let's add another if node with a datetime condition we are going to check if a Google form was submitted 4 hours ago at the next workflow execution unanswered forms which were submitted 4 hours ago will pass this condition you can add more operations to send chat notification or an email with n you have a lot of possibilities to enhance this automation even further finally we can add a new Crown trigger to run this automation on a regular basis pick the custom trigger interval and provide the cron rule for example you can make this automation run every half an hour from early morning till late evening on weekdays don't forget to connect the schedule trigger to both data sources and activate the workflow congratulations you've successfully created a workflow that integrates Google Sheets with my SQL using n whenever a new Google form is submitted a new row appears in the underlying spreadsheet which is then synced in my SQL database once the submissions are reviewed their status is synced back into the spreadsheet making this automation reliable and stable in the long run finally you can add new nodes and send notifications if any of the form submissions are not reviewed on time this is just one workflow example but you can create many other use cases for Google Sheets and SQL integration if you have any questions please leave a comment below the video also let us know about other Integrations you would like to see on this channel NN is absolutely a great tool for complex workflows so be sure to check out the links in the description below see you next time
