# 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:

`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"` [\[Example In Sandbox\]](https://www.usesql.com/demo?query=SELECT%20*%20FROM%20%22mysql%3A%2F%2Fusername%3Apassword%40host%3Aport%2Fdatabase.table%22\&format=csv)

### 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.

![](/files/-MYpVw_XLauDBBXpMres)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.usesql.com/tutorials/displaying-reports-in-google-sheets-from-mysql.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
