Displaying reports in Google Sheets from MySQL

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.

Step 1: Build your query string

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:


Step 2: Add your query string to your 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]

Step 3: Embed results in your Google Sheet

To embed your results you just need to wrap your query from above in the =IMPORTDATA function.

Last updated