UseSQL
  • Introduction
  • Getting Started
    • Source Formats
    • Output Formats
    • Managing Keys
    • Sandbox
    • Saved Queries
  • Client Libraries
    • HTML Templating
    • JavaScript Web Client
  • Tutorials
    • Integrate With Your Static Site
    • Share Data In Slack
    • Show external query results in a Google Sheet
    • Query across a Google Sheet and a CSV file
    • Securing Your Key
    • Querying Airtable
    • Integrate With ProcFu
    • Integrate with a private Google Sheet
    • Updating Google Sheets
    • Retrieving data from tables on a web page
    • Displaying reports in Google Sheets from MySQL
    • Querying StackBy Tables
  • Resources
    • Demo Sandbox
    • OpenAPI Docs
    • Redoc API Docs
    • Roadmap
    • Changelog
Powered by GitBook
On this page
  • Step 1: Build your query string
  • Step 2: Add your query string to your table
  • Step 3: Embed results in your Google Sheet

Was this helpful?

  1. Tutorials

Displaying reports in Google Sheets from MySQL

PreviousRetrieving data from tables on a web pageNextQuerying StackBy Tables

Last updated 4 years ago

Was this helpful?

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:

mysql://username:password@host:port/database.table

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"

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.

[Example In Sandbox]