Apache Zeppelin is a web-based notebook product that enables interactive data analysis. Apache Zeppelin is integrated with abundant language backends or interpreters, such as Scala, Python, Spark SQL, and Hive. This helps you create interactive, collaborative documents. This topic describes how to use Apache Zeppelin to connect to AnalyticDB for PostgreSQL and perform visualized analysis.
Prerequisites
An AnalyticDB for PostgreSQL data source is prepared.
Procedure
Install Apache Zeppelin. For more information, see Apache Zeppelin official documentation.
Configure an interpreter.
Log on to Apache Zeppelin, click the username in the upper-right corner of the page, and then select Interpreter from the drop-down list.
In the upper-right corner of the Interpreters page, click Create to create an interpreter.
Set the Interpreter group parameter to JDBC. In this example, an interpreter named jdbc-test is created.
NoteIn the latest version of Apache Zeppelin, the PostgreSQL interpreter is no longer used and its features are merged into the JDBC interpreter. You can use the JDBC interpreter that provides the same features to connect to AnalyticDB for PostgreSQL.
After you set the Interpreter group parameter to JDBC, configure the parameters that are described in the following table.
Parameter
Description
default.url
The Java Database Connectivity (JDBC) URL that is used to connect to AnalyticDB for PostgreSQL. Specify the value in the format of
jdbc:postgresql://{host}:{port}/{database}
. The JDBC URL contains the following variables:host: the endpoint of the instance. You can go to the Basic Information page of the AnalyticDB for PostgreSQL instance and obtain the endpoint from the Database Connection Information section.
Port: the port number of the instance. You can go to the Basic Information page of the AnalyticDB for PostgreSQL instance and obtain the port number from the Database Connection Information section.
database: the name of the database.
default.user
The username of the database account that is used to connect to the database.
default.password
The password of the database account.
You can configure other parameters based on your business requirements. For more information, see Apache Zeppelin official documentation.
Click Save in the lower part of the page to save the settings.
Create a notebook and perform data analysis.
In the top navigation bar, choose Notebook > Create new note.
Enter a note name and set the Default Interpreter parameter to the interpreter that you created. Example: jdbc-test.
Click Create.
Write an SQL statement in the notebook and perform data analysis.
You must add the name of the interpreter, such as
%jdbc-test
, before the SQL statement. This way, Apache Zeppelin can use the specified interpreter to generate and send a query request. You can specify the way to display data on the page. The query result is displayed in the lower part of the page.