Is this tutorial worth your time?
There are 2 main steps:
Let me show you the steps!
If you want to connect your Google spreadsheet to MySQL, here I’ll share with you the code to read data from your SQL database (here with MySQL) and import the whole table in Google Sheets.
1. Create a new Google Sheets by typing sheet.new in your browser toolbar
2. Name your spreadsheet by doubling clicking on the default name Untitled spreadsheet on the top left hand corner and replacing it with the name you want. For instance, I chose to name it Test here.
3. Click on Tools > Script editor, this will open a new tab with a url starting with https://script.google.com/.
4. Name your script by clicking on the default name Untitled project on the top left hand corner. A little window will pop up where you can write the name you choose. For instance, I chose to name it like my spreadsheet: Test. Then, click on the OK button.
5. Apps Script can connect to external databases through the JDBC service. It supports Google Cloud SQL, MySQL, Microsoft SQL Server, and Oracle databases. To update an external database with JDBC, your script must open a connection to the database and then make changes by sending SQL statements. In order to create a database connection using the JDBC service you must whitelist certain IP ranges in your database settings to allow Apps Script to access it. These are the address ranges you'll need to whitelist:
6. In the code area, you’ll see some code already written:
7. Delete this code.
8. Copy and paste the code below in the code area:
9. Replace the following information with your own in the code:
10. Click on the Run button (the arrow pointing to the bug on its right). Or, in the menu, on Run > Run function > readData.
11. A little window will pop up entitled Authorization required. Click on the Review Permissions button.
12. You might need to click in order to choose the Google account you are using to run your script. Click on the Allow button.
13. On top of your script, you’ll see a little message stating Running function readData… (be patient, it might take a while)
14. When the message disappears, go back to your sheet and… VOILA! You’ll have retrieved your SQL data in your spreadsheet :)
How do you feel right now? On my end, I felt so much joy when I managed to retrieve the data from my database! #proud
Now I’ll show you the code to fetch and refresh your data every minute. Each time, it clears the existing content in the chosen sheet and replace it with the database data while keeping the format you gave to the table in Google Sheets.
1. Just add this piece of code at the end of your current code:
2. Click on the Run button (the arrow pointing to the bug on its right). If a little window will pop up entitled Authorization required, allow it again.
That’s it! Now, you will import and automatically sync your data between your SQL database and Google Sheets. Yes, so simple and yet so powerful…
google spreadsheet to mysql ; google sheets mysql ; connect google sheets to mysql ; google sheet connect to mysql ; google sheets to mysql ; connect mysql to google sheets ; google sheets connect to mysql ; google sheet mysql ; mysql google sheets ; google sheets mysql connector ; google sheets mysql connection ; google spreadsheet mysql ; sync google sheets with mysql ; google sheet to mysql ; connect google sheet to mysql ; connect google spreadsheet to mysql server
Oh, and if you think this whole thing is a painful process, feel free to check out our product Actiondesk, it's a spreadsheet software that lets you import and refresh data seamlessly from SQL, Stripe, Salesforce, Hubspot and more.