Merge pull request #29068 from taosdata/docs/TD-33062-MAIN

Docs :   python connector support SuperSet  product document
This commit is contained in:
Linhe Huo 2024-12-17 09:21:39 +08:00 committed by GitHub
commit a3376e00d3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 159 additions and 10 deletions

View File

@ -0,0 +1,76 @@
---
sidebar_label: Superset
title: Integration With Superset
toc_max_heading_level: 4
---
Apache Superset is a modern enterprise level business intelligence (BI) web application primarily used for data exploration and visualization.
It is supported by the Apache Software Foundation and is an open source project with an active community and rich ecosystem.
Apache Superset provides an intuitive user interface that makes creating, sharing, and visualizing data simple, while supporting multiple data sources and rich visualization options.
Through the Python connector of TDengine, Superset can support TDengine data sources and provide functions such as data presentation and analysis
## Install Apache Superset
Ensure that Apache Superset v2.1.0 or above is installed. If not, please visit [official website](https://superset.apache.org/) to install
## Install TDengine
Both TDengine Enterprise Edition and Community Edition are supported, with version requirements of 3.0 or higher
## Install TDengine Python Connector
The Python connector of TDengine comes with a connection driver that supports Superset in versions 2.1.18 and later, which will be automatically installed in the Superset directory and provide data source services.
The connection uses the WebSocket protocol, so it is necessary to install the `taos-ws-py` component of TDengine separately. The complete installation script is as follows:
```bash
pip3 install taospy
pip3 install taos-ws-py
```
## Configure TDengine Connection In Superset
**Step 1**, enter the new database connection page, "Superset" → "Setting" → "Database Connections" → "+DATABASE"
**Step 2**, select TDengine database connection, select the "TDengine" option from the drop-down list of "SUPPORTED DATABASES".
:::tip
If there is no TDengine option in the drop-down list, please confirm that the steps of installing, `Superset` is first and `Python Connector` is second.
:::
**Step 3**, write a name of connection in "DISPLAY NAME"
**Step 4**, The "SQLALCHEMY URL" field is a key connection information string, and it must be filled in correctly
```bash
taosws://user:password@host:port
```
| Parameter | <center>Parameter Description</center> |
|:---------- |:--------------------------------------------------------- |
|user | Username for logging into TDengine database |
|password | Password for logging into TDengine database |
|host | Name of the host where the TDengine database is located |
|port | The port that provides WebSocket services, default is 6041 |
Example:
The TDengine database installed on this machine provides WebSocket service port 6041, using the default username and password, "SQLALCHEMY URL" is:
```bash
taosws://root:taosdata@localhost:6041
```
**Step 5**, configure the connection string, click "TEST CONNECTION" to test if the connection can be successful. After passing the test, click the "CONNECT" button to complete the connection
## Start
There is no difference in the use of TDengine data source compared to other data sources. Here is a brief introduction to basic data queries:
1. Click the "+" button in the upper right corner of the Superset interface, select "SQL query", and enter the query interface
2. Select the "TDengine" data source that has been created earlier from the dropdown list of "DATABASES" in the upper left corner
3. Select the name of the database to be operated on from the drop-down list of "SCHEMA" (system libraries are not displayed)
4. "SEE TABLE SCHEMA" select the name of the super table or regular table to be operated on (sub tables are not displayed)
5. Subsequently, the schema information of the selected table will be displayed in the following area
6. In the SQL editor area, any SQL statement that conforms to TDengine syntax can be entered for execution
## Example
We chose two popular templates from the Superset Chart template to showcase their effects, using smart meter data as an example:
1. "Aggregate" Type, which displays the maximum voltage value collected per minute during the specified time period in Group 4
![superset-demo1](./superset-demo1.jpeg)
2. "RAW RECORDS" Type, which displays the collected values of current and voltage during the specified time period in Group 4
![superset-demo2](./superset-demo2.jpeg)

Binary file not shown.

After

Width:  |  Height:  |  Size: 650 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 784 KiB

View File

@ -22,24 +22,24 @@ toc_max_heading_level: 4
配置JDBC数据源的步骤如下。
第1步在打开的永洪BI中点击“添加数据源”按钮选择SQL数据源中的“GENERIC”类型。
第2步点击“选择自定义驱动”按钮在“驱动管理”对话框中点击“驱动列表”旁边的“+”输入名称“MyTDengine”。然后点击“上传文件”按钮上传刚刚下载的TDengine JDBC连接器文件“taos-jdbcdriver-3.2.7-dist.jar”并选择“com.taosdata.jdbc.
rs.RestfulDriver”驱动最后点击“确定”按钮完成驱动添加步骤。
第3步复制下面的内容到“URL”字段。
第1步在打开的永洪BI中点击“添加数据源”按钮选择SQL数据源中的“GENERIC”类型。
第2步点击“选择自定义驱动”按钮在“驱动管理”对话框中点击“驱动列表”旁边的“+”输入名称“MyTDengine”。然后点击“上传文件”按钮上传刚刚下载的TDengine JDBC连接器文件“taos-jdbcdriver-3.2.7-dist.jar”并选择“com.taosdata.jdbc.
rs.RestfulDriver”驱动最后点击“确定”按钮完成驱动添加步骤。
第3步复制下面的内容到“URL”字段。
```text
jdbc:TAOS-RS://127.0.0.1:6041?user=root&password=taosdata
```
第4步在“认证方式”中点击“无身份认证”单选按钮。
第5步在数据源的高级设置中修改“Quote 符号”的值为反引号(`)。
第6步点击“测试连接”按钮弹出“测试成功”对话框。点击“保存”按钮输入“MyTDengine”来保存TDengine数据源。
第4步在“认证方式”中点击“无身份认证”单选按钮。
第5步在数据源的高级设置中修改“Quote 符号”的值为反引号(`)。
第6步点击“测试连接”按钮弹出“测试成功”对话框。点击“保存”按钮输入“MyTDengine”来保存TDengine数据源。
## 创建TDengine数据集
创建TDengine数据集的步骤如下。
第1步在永洪BI中点击“添加数据源”按钮展开刚刚创建的数据源并浏览TDengine中的超级表。
第2步可以将超级表的数据全部加载到永洪BI中也可以通过自定义SQL导入部分数据。
第3步当勾选“数据库内计算”复选框时永洪BI将不再缓存TDengine的时序数据并在处理查询时将SQL请求发送给TDengine直接处理。
第1步在永洪BI中点击“添加数据源”按钮展开刚刚创建的数据源并浏览TDengine中的超级表。
第2步可以将超级表的数据全部加载到永洪BI中也可以通过自定义SQL导入部分数据。
第3步当勾选“数据库内计算”复选框时永洪BI将不再缓存TDengine的时序数据并在处理查询时将SQL请求发送给TDengine直接处理。
当导入数据后永洪BI会自动将数值类型设置为“度量”列将文本类型设置为“维度”列。而在TDengine的超级表中由于将普通列作为数据的度量将标签列作为数据的维度因此用户可能需要在创建数据集时更改部分列的属性。TDengine在支持标准SQL的基础之上还提供了一系列满足时序业务场景需求的特色查询语法例如数据切分查询、窗口切分查询等具体操作步骤请参阅TDengine的官方文档。通过使用这些特色查询当永洪BI将SQL查询发送到TDengine时可以大大提高数据访问速度减少网络传输带宽。

View File

@ -0,0 +1,73 @@
---
sidebar_label: Superset
title: 与 Superset 集成
---
Apache Superset 是一个现代的企业级商业智能BIWeb 应用程序,主要用于数据探索和可视化。它由 Apache 软件基金会支持是一个开源项目它拥有活跃的社区和丰富的生态系统。Apache Superset 提供了直观的用户界面,使得创建、分享和可视化数据变得简单,同时支持多种数据源和丰富的可视化选项‌。
通过 TDengine 的 Python 连接器, Superset 可支持 TDengine 数据源并提供数据展现、分析等功能
## 安装 Apache Superset
确保已安装 Apache Superset v2.1.0 及以上版本, 如未安装,请到其 [官网](https://superset.apache.org/) 安装
## 安装 TDengine
TDengine 企业版及社区版均可支持,版本要求在 3.0 及以上
## 安装 TDengine Python 连接器
TDengine Python 连接器从 `v2.1.18` 开始自带 Superset 连接驱动,安装程序会把连接驱动安装到 Superset 相应目录下并向 Superset 提供数据源服务
Superset 与 TDengine 之间使用 WebSocket 协议连接,所以需另安装支持 WebSocket 连接协议的组件 `taos-ws-py` , 全部安装脚本如下:
```bash
pip3 install taospy
pip3 install taos-ws-py
```
## Superset 中配置 TDengine 连接
**第 1 步**,进入新建数据库连接页面 "Superset" → "Setting" → "Database Connections" → "+DATABASE"
**第 2 步**,选择 TDengine 数据库连接。"SUPPORTED DATABASES" 下拉列表中选择 "TDengine" 项。
:::tip
注意:若下拉列表中无 "TDengine" 项,请检查安装顺序,确保 `TDengine Python 连接器``Superset` 安装之后再安装。
:::
**第 3 步**"DISPLAY NAME" 中填写连接名称,任意填写即可。
**第 4 步**"SQLALCHEMY URL" 项为关键连接信息串,务必填写正确。
```bash
taosws://用户名:密码@主机名:端口号
```
| 参数名称 | <center>参数说明</center> |
|:------- |:-------------------------------- |
| 用户名 | 登录 TDengine 数据库用户名 |
| 密码 | 登录 TDengine 数据库密码 |
| 主机名 | TDengine 数据库所在主机名称 |
| 端口号 | 提供 WebSocket 服务的端口默认6041 |
示例:
本机安装 TDengine 数据库WebSocket 服务端口 6041使用默认用户名密码"SQLALCHEMY URL" 应为:
```bash
taosws://root:taosdata@localhost:6041
```
第5步配置好连接串点击 “TEST CONNECTION” 测试连接是否成功,测试通过后点击 “CONNECT” 按钮,完成连接。
## 开始使用
TDengine 数据源与其它数据源使用上无差别,这里简单介绍下数据查询:
1. Superset 界面点击右上角 “+” 号按钮,选择 “SQL query”, 进入查询界面
2. 左上角 “DATABASE” 下拉列表中选择前面已创建好的 “TDengine” 数据源
3. “SCHEMA” 下拉列表,选择要操作的数据库名(系统库不显示)
4. “SEE TABLE SCHEMA” 选择要操作的超级表名或普通表名(子表不显示)
5. 随后会在下方显示选定表的 SCHEMA 信息
6. 在 SQL 编辑器区域可输入符合 TDengine 语法的任意 SQL 语句执行
## 示例效果
我们选择 Superset Chart 模板中较流行的两个模板做了效果展示,以智能电表数据为例:
1. "Aggregate" 类型,展示在第 4 组中指定时间段内每分钟采集电压值(voltage)最大值
![superset-demo1](./superset-demo1.jpeg)
2. "RAW RECORDS" 类型,展示在第 4 组中指定时间段内 current, voltage 的采集值
![superset-demo2](./superset-demo2.jpeg)

Binary file not shown.

After

Width:  |  Height:  |  Size: 650 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 784 KiB