Connect to TiDB Cloud Lake with Apache Superset
Apache Superset is an open-source data exploration and visualization platform. Superset connects to TiDB Cloud Lake through the TiDB Cloud Lake dialect for SQLAlchemy.
Prerequisites
Before you begin, make sure that you have the following:
- Docker
- A TiDB Cloud Lake account, database, and warehouse
- The host, username, password, database, and warehouse name for your connection
For information about obtaining connection information, see Connect to a Warehouse.
Build a Superset image
The official Superset image does not include the TiDB Cloud Lake SQLAlchemy dialect. Create a file named Dockerfile with the following content:
FROM apache/superset
USER root
RUN pip install --no-cache-dir tidbcloudlake-sqlalchemy
USER superset
The tidbcloudlake-sqlalchemy package installs the required TiDB Cloud Lake Python driver as a dependency.
Build the image:
docker build -t superset-lake .
Start a container from the image:
docker run -d \
-p 8080:8088 \
-e "SUPERSET_SECRET_KEY=<your-secret-key>" \
--name superset \
superset-lake
Initialize Superset
Create an administrator account:
docker exec -it superset superset fab create-admin \
--username admin \
--firstname Superset \
--lastname Admin \
--email admin@example.com \
--password <admin-password>
Apply database migrations:
docker exec -it superset superset db upgrade
Initialize Superset:
docker exec -it superset superset init
Open http://localhost:8080 and sign in with the administrator account.
Connect Superset to TiDB Cloud Lake
In Superset, select Settings > Data > Connect Database.
Select Other as the database type.
Enter a display name, such as
TiDB Cloud Lake.Enter the SQLAlchemy URI in the following format:
lake://<username>:<password>@<host>:443/<database>?warehouse=<warehouse>Click Test Connection.
After the connection test succeeds, click Connect.
You can now create datasets in Superset from TiDB Cloud Lake tables and use them in charts and dashboards.