> ## Documentation Index
> Fetch the complete documentation index at: /documents/llms.txt
> Use this file to discover all available pages before exploring further.

# 支持 Superset

> Apache Superset 是现代数据探索和可视化平台，可连接 数据库 进行数据分析。

[Apache Superset](https://superset.apache.org) 是一个现代数据探索和可视化平台。它使用 [SQLAlchemy](https://github.com/StarRocks/starrocks/tree/main/contrib/starrocks-python-client/starrocks) 来查询数据。
虽然可以使用 Mysql Dialect，但是它不支持 LARGEINT。所以我们开发了 [StarRocks Dialect](https://github.com/StarRocks/starrocks/tree/main/contrib/starrocks-python-client/starrocks/)。

## 环境准备

* Python 3.x
* mysqlclient (pip install mysqlclient)
* [Apache Superset](https://superset.apache.org)

注意: 如果没有安装 `mysqlclient`，将抛出异常: No module named 'MySQLdb'。

## 安装

由于 `dialect` 还没有贡献给 SQLAlchemy 社区，需要使用源码进行安装。

如果你使用 Docker 安装 Superset，需要使用 `root` 用户安装 `sqlalchemy-starrocks`。

安装通过[源码](https://github.com/StarRocks/starrocks/tree/main/contrib/starrocks-python-client/starrocks)。

```shell theme={null}
pip install .
```

卸载

```shell theme={null}
pip uninstall sqlalchemy-starrocks
```

## 使用

通过 SQLAlchemy 连接 数据库，可以使用下述链接：

```shell theme={null}
starrocks://<username>:<password>@<host>:<port>/<database>[?charset=utf8]
```

## 示例

### Sqlalchemy 示例

建议使用 python 3.x 连接 数据库，比如：

```shell theme={null}
from sqlalchemy import create_engine
import pandas as pd
conn = create_engine('starrocks://root:@x.x.x.x:9030/superset_db?charset=utf8')
sql = """select * from xxx"""
df = pd.read_sql(sql, conn)
```

### Superset 示例

使用 Superset 时，使用 `Other` 数据库连接，并且设置 url 为：

```shell theme={null}
starrocks://root:@x.x.x.x:9030/superset_db?charset=utf8
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.