All Products
Search
Document Center

AnalyticDB:Use Apache Superset to connect to AnalyticDB for PostgreSQL

Last Updated:Jun 21, 2024

Apache Superset is a business intelligence (BI) tool that enables data exploration and visualized analysis. Apache Superset is developed based on Python by using components such as Flask, Pandas, and SQLAlchemy. You can use Apache Superset to produce visualized, interactive, and collaborative documents. This topic describes how to use Apache Superset to connect to AnalyticDB for PostgreSQL for visualized analysis.

Prerequisites

  • An AnalyticDB for PostgreSQL instance is created as the data source.

  • Apache Superset is installed. For more information, visit the Apache Superset official website.

Procedure

  1. Start Apache Superset. In the top navigation bar, choose Sources > Databases to go to the Databases page.

    1.png

  2. In the upper-right corner of the page, click the 图标.png icon. On the Add Database page, configure the parameters that are described in the following table to add a data source.

    Parameter

    Description

    Database

    The name of the database.

    SQLAlchemy URI

    The connection string that is used to connect to the AnalyticDB for PostgreSQL database. Format:

    postgresql+psycopg2://<AccessKey ID>:<AccessKey Secret>@<host>:<port}>/<Database>

    An SQLAlchemy URI contains the following parameters:

    • AccessKey ID and AccessKey Secret: the AccessKey ID and AccessKey secret of your Alibaba Cloud account. For more information, see Create an AccessKey pair.

    • host: the internal endpoint of the AnalyticDB for PostgreSQL instance. You can log on to the AnalyticDB for PostgreSQL console and go to the Database Connection page of the instance to obtain the internal endpoint.

    • port: the port number of the AnalyticDB for PostgreSQL instance. Default value: 5432.

    • Database: the name of the database in the AnalyticDB for PostgreSQL instance.

    For more information about the connection information, see the SQLAlchemy documentation.

  3. Click Test Connection to check whether the connection is established and whether the settings of the connection are valid.

  4. If the connection is successful, click Save in the lower part of the page.

    After you use Apache Superset to connect to AnalyticDB for PostgreSQL, you can analyze data in a visualized manner. For more information, see the Apache Superset documentation.