Displaying reports in Google Sheets from MySQL
Last updated
Last updated
A common use case that UseSQL can serve is to display data and build reports in Google Sheets. The API has the ability to query MySQL tables and views, and soon the ability to provide queries as a source. This tutorial will demonstrate how to surface results from a table or view into a Google Sheet.
Note: When doing this you are exposing your credentials within the Google Sheet so please use a protected Sheet and read-only credentials.
To create a MySQL source to be queried it's pretty simple. You just need to provide the connection string with the table or view you want to query. The query string below shows how this should look:
mysql://username:password@host:port/database.table
After that, you can add that as a source to query, and set the return format to be csv. For demonstration purposes, we will keep this simple.
SELECT * FROM "mysql://username:password@host:port/database.table"
[Example In Sandbox]
To embed your results you just need to wrap your query from above in the =IMPORTDATA
function.