Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TiDB Cloud: add a tutorial for Looker Studio #16111

Merged
merged 22 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
f6ffc68
TiDB Cloud: add a tutorial for Looker Studio
bohnen Jan 11, 2024
de82576
TiDB Cloud: fix support link
bohnen Jan 11, 2024
da6d79e
Update TOC-tidb-cloud.md
bohnen Jan 11, 2024
e838521
Update develop/dev-guide-bi-looker-stduio.md
bohnen Jan 11, 2024
9d286a8
Update develop/dev-guide-bi-looker-stduio.md
bohnen Jan 11, 2024
3d197c1
fix filename typo
bohnen Jan 11, 2024
77836d6
add separate connection description for a dedicated cluster
bohnen Jan 11, 2024
0754c61
change support link to /support.md
bohnen Jan 11, 2024
b337bf6
revert support link change due to braking CI
bohnen Jan 11, 2024
f686612
restrict access from specific IP range
bohnen Jan 11, 2024
328ba79
fix lint error: double space after list marker
bohnen Jan 11, 2024
d040ac3
Apply suggestions from code review
bohnen Jan 11, 2024
911db94
Apply suggestions from code review
zhangyangyu May 11, 2024
bbfbc22
Update develop/dev-guide-bi-looker-studio.md
zhangyangyu May 12, 2024
cee640f
Apply suggestions from code review
zhangyangyu May 12, 2024
8efcb86
refine the content and update the instructions for TiDB Dedicated
qiancai May 13, 2024
631a756
move the doc to the tidb-cloud folder as it is only for TiDB Cloud
qiancai May 13, 2024
ad69eb9
Update dev-guide-bi-looker-studio.md
qiancai May 13, 2024
0254ba5
Update dev-guide-bi-looker-studio.md
qiancai May 13, 2024
87745cd
Update looker-studio-simple-chart.png
qiancai May 14, 2024
2dea8f0
Apply suggestions from code review
qiancai May 14, 2024
95f2ca7
format udpates
qiancai May 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions TOC-tidb-cloud.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
- [MySQL Workbench](/develop/dev-guide-gui-mysql-workbench.md)
- [Navicat](/develop/dev-guide-gui-navicat.md)
- [Choose Driver or ORM](/develop/dev-guide-choose-driver-or-orm.md)
- BI
- [Looker Studio](/develop/dev-guide-bi-looker-studio.md)
- Java
- [JDBC](/develop/dev-guide-sample-application-java-jdbc.md)
- [MyBatis](/develop/dev-guide-sample-application-java-mybatis.md)
Expand Down
174 changes: 174 additions & 0 deletions develop/dev-guide-bi-looker-studio.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
---
title: Connect to TiDB Cloud with Looker Studio
summary: Learn how to connect to TiDB Cloud using Looker Studio
zhangyangyu marked this conversation as resolved.
Show resolved Hide resolved
---

# Connect to TiDB Cloud with Looker Studio

TiDB is a MySQL-compatible database, and [Looker Studio](https://lookerstudio.google.com/) is a free web-based BI tool that can visualize data from various sources.

In this tutorial, you can learn how to connect to your TiDB cluster using Looker Studio.

> **Note:**
>
> - For this tutorial we will use a serverless cluster. Looker Studio can also be used with dedicated clusters.
zhangyangyu marked this conversation as resolved.
Show resolved Hide resolved
zhangyangyu marked this conversation as resolved.
Show resolved Hide resolved

## Prerequisites

To complete this tutorial, you need:

- Google Account.
- A TiDB cluster.

**If you don't have a TiDB cluster, you can create one as follows:**

- Follow [Creating a TiDB Serverless cluster](/develop/dev-guide-build-cluster-in-cloud.md) to create your own TiDB Serverless cluster.

## Import Dataset

<SimpleTab>

You can use the S&P 500 dataset provided as an Interactive Tutorial of TiDB Serverless.

<div label="TiDB Serverless">

1. Navigate to the [**Clusters**](https://tidbcloud.com/console/clusters) page, and click the question mark icon in the bottom-right corner. A Help dialog is displayed.
zhangyangyu marked this conversation as resolved.
Show resolved Hide resolved

2. Click **Interactive Tutorials**. Then click **S&P 500 Analysis**.
zhangyangyu marked this conversation as resolved.
Show resolved Hide resolved

3. In the **Import S&P 500 Dataset** dialog, select your Serverless cluster. Then click the **Import Dataset** button. It will start importing briefly.
zhangyangyu marked this conversation as resolved.
Show resolved Hide resolved

4. After the status changed to **Imported**, you can close this dialog. Click the **Exit Tutorial** button in the bottom-left corner of the dialog.
zhangyangyu marked this conversation as resolved.
Show resolved Hide resolved

</div>

## Connect to TiDB cluster

<SimpleTab>
<div label="TiDB Serverless">

1. Navigate to the [**Clusters**](https://tidbcloud.com/console/clusters) page, and then click the name of your target cluster to go to its overview page.

2. Click **Connect** in the upper-right corner. A connection dialog is displayed.

3. Set **Operating System** to `Windows` in the connection dialog. Then Set **Connect With** to `General`. You can download [CA cert](https://letsencrypt.org/certs/isrgrootx1.pem) at the note below.
zhangyangyu marked this conversation as resolved.
Show resolved Hide resolved

> **Tip:**
>
> As TiDB Serverless requires a secure TLS connection between the client and the cluster, you need this CA cert for connection settings on Looker Studio.

4. Click **Generate Password** to create a random password.

> **Tip:**
>
> If you have created a password before, use the original password or click **Reset Password** to generate a new one.
zhangyangyu marked this conversation as resolved.
Show resolved Hide resolved

5. Open Looker Studio and create a Blank Report. Select the' MySQL' connector in the **Add data to report** screen.
bohnen marked this conversation as resolved.
Show resolved Hide resolved

6. In the **BASIC** setting pane, configure the following connection parameters:

- **Host Name or IP**: enter the `HOST` parameter from the TiDB Cloud connection dialog.
- **Port(Optional)**: enter the `PORT` parameter from the TiDB Cloud connection dialog.
- **Database**: enter the database you want to connect to. In this tutorial, set `sp500insight`.
zhangyangyu marked this conversation as resolved.
Show resolved Hide resolved
- **Username**: enter the `USERNAME` parameter from the TiDB Cloud connection dialog.
- **Password**: enter the `PASSWORD` parameter from the TiDB Cloud connection dialog.
- Check **Enable SSL**.
zhangyangyu marked this conversation as resolved.
Show resolved Hide resolved
- Click the icon on the right of **MySQL SSL Client Configuration Files**. Then, select the downloaded CA file in step 3.
zhangyangyu marked this conversation as resolved.
Show resolved Hide resolved

![Looker Studio: configure connection settings for TiDB cloud](/media/develop/looker-studio-configure-connection.png)

7. Click **AUTHENTICATE**.

If the authentication succeeds, you can see tables in the database.

</div>
<div label="TiDB Dedicated">

1. Navigate to the [**Clusters**](https://tidbcloud.com/console/clusters) page, and then click the name of your target cluster to go to its overview page.

2. Click **...** menu in the upper-right corner. Then, select **Security Settings**. Settings dialog shows up.

3. Click **Generate** to generate root password and **Copy** it to the clipboard.

> **Tip:**
>
> If you have created a password before, use the original password or click **Regenerate** to generate a new one.

4. Click **Apply** to close the dialog.

5. Click **Connect** in the upper-right corner. A connection dialog is displayed.

6. Click **Allow Access from Anywhere(Insecure)**.
zhangyangyu marked this conversation as resolved.
Show resolved Hide resolved

For more details about how to obtain the connection string, refer to [TiDB Dedicated standard connection](https://docs.pingcap.com/tidbcloud/connect-via-standard-connection).

7. You can download CA File with the link under **Step 2**.

8. Open Looker Studio and create a Blank Report. Select the' MySQL' connector in the **Add data to report** screen.
bohnen marked this conversation as resolved.
Show resolved Hide resolved

9. In the **BASIC** setting pane, configure the following connection parameters:

- **Host Name or IP**: enter the `HOST` parameter from the TiDB Cloud connection dialog.
- **Port(Optional)**: enter the `PORT` parameter from the TiDB Cloud connection dialog.
- **Database**: enter the database you want to connect to. In this tutorial, set `sp500insight`.
- **Username**: enter the `USERNAME` parameter from the TiDB Cloud connection dialog.
- **Password**: enter the `PASSWORD` parameter from the TiDB Cloud connection dialog.
- Check **Enable SSL**.
- Click the icon on the right of **MySQL SSL Client Configuration Files**. Then, select the downloaded CA file before.

10. Click **AUTHENTICATE**.

If the authentication succeeds, you can see tables in the database.
zhangyangyu marked this conversation as resolved.
Show resolved Hide resolved
</div>
</SimpleTab>

## Create a simple chart

Now, you can use TiDB cluster as a data source. Let's make a simple chart with data.
zhangyangyu marked this conversation as resolved.
Show resolved Hide resolved

1. In the setting pane, select **CUSTOM QUERY**.
zhangyangyu marked this conversation as resolved.
Show resolved Hide resolved

2. Put the SQL below, then click **Add** in the bottom-right corner.

```sql
SELECT sector,
COUNT(*) AS companies,
ROW_NUMBER() OVER (ORDER BY COUNT(*) DESC ) AS companies_ranking,
SUM(market_cap) AS total_market_cap,
ROW_NUMBER() OVER (ORDER BY SUM(market_cap) DESC ) AS total_market_cap_ranking,
SUM(revenue_growth * weight) / SUM(weight) AS avg_revenue_growth,
ROW_NUMBER() OVER (ORDER BY SUM(revenue_growth * weight) / SUM(weight) DESC ) AS avg_revenue_growth_ranking
FROM companies
LEFT JOIN index_compositions ic ON companies.stock_symbol = ic.stock_symbol
GROUP BY sector
ORDER BY 5 ASC
zhangyangyu marked this conversation as resolved.
Show resolved Hide resolved
```

If you see **You are about to add data to this report** dialog, click **ADD TO REPORT**.
zhangyangyu marked this conversation as resolved.
Show resolved Hide resolved

3. You see a table in the report. Click **Add a chart**, then select `Combo chart` in the `Line` category.
zhangyangyu marked this conversation as resolved.
Show resolved Hide resolved

4. In the **Chart** settings pane, configure the following parameters:

- **Dimension**: `sector`.
- **Metric**: `companies` and `total_market_cap`.
zhangyangyu marked this conversation as resolved.
Show resolved Hide resolved
- In the **STYLE** Tab:
- Series #1 check `Line`.
- Series #1 axis `Right`.
- Series #2 check `Bars`.
- Series #2 axis `Left`.
zhangyangyu marked this conversation as resolved.
Show resolved Hide resolved
- Leave others as defaults.

You can see a combo chart below:
zhangyangyu marked this conversation as resolved.
Show resolved Hide resolved

![Looker Studio: A simple Combo Chart](/media/develop/looker-studio-simple-chart.png)

## Next steps

- Learn more usage of Looker Studio from [Looker Studio Help](https://support.google.com/looker-studio)
zhangyangyu marked this conversation as resolved.
Show resolved Hide resolved
- Learn the best practices for TiDB application development with the chapters in the [Developer guide](/develop/dev-guide-overview.md), such as [Insert data](/develop/dev-guide-insert-data.md), [Update data](/develop/dev-guide-update-data.md), [Delete data](/develop/dev-guide-delete-data.md), [Single table reading](/develop/dev-guide-get-data-from-single-table.md), [Transactions](/develop/dev-guide-transaction-overview.md), and [SQL performance optimization](/develop/dev-guide-optimize-sql-overview.md).
- Learn through the professional [TiDB developer courses](https://www.pingcap.com/education/) and earn [TiDB certifications](https://www.pingcap.com/education/certification/) after passing the exam.

## Need help?

Ask questions on [Discord](https://discord.gg/DQZ2dy3cuc?utm_source=doc) or [create a support ticket](https://support.pingcap.com/).
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/develop/looker-studio-simple-chart.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading