DBeaver is a popular open-source tool used for database management and as an SQL client. This article explains how to use DBeaver with a TDengine time-series database (TSDB).
In this article, DBeaver 22.1.2 is used to connect with TDengine 2.6 using the TDengine REST API.
Configuring DBeaver for TDengine
To install and configure DBeaver, perform the following steps:
- Download the TDengine JDBC driver.
- In a Web browser, open the Maven Central Repository Search page.
- Search for
com.taosdata.jdbc
and click the Download icon. - Select the
dist.jar
format and save the file to your local machine.
- Download and install the DBeaver package from the official website.
- Once installation is complete, open DBeaver. From the main menu, select Database > Driver Manager and click New.
- In the Create new driver window, open the Libraries tab and click Add file. Select the JAR file that you downloaded in Step 1 and click Open.
- At the bottom of the window, click Find Class. Then, select
com.taosdata.jdbc.rs.RestfulDriver
in the Driver class field. - Open the Settings tab and enter a name for the driver. Then enter the URL template, port, database, and user for your TDengine deployment. The format for the URL template is as follows:
jdbc:TAOS-RS://<host-name>:<port>/<database_name>?user=<user>&password=<password>
- Select Database > New Database Connection, open the All tab, and search for the driver that you created. Click Next.
- Enter the URL for your TDengine deployment and click Test Connection.
Verification
- Once the connection is successful, your TDengine database is displayed in the Database Navigator window. You can click on tables within the database to show the schema and data contained in each table.
- From the main menu, select SQL Editor > Open SQL Console and enter SQL statements to verify that the connection is working properly. Note: RESTful requests are stateless. For this reason, you must include the database name in queries and writes.
- As an example, you can enter
SHOW log.stables;
to display all supertables in the defaultlog
database. - You can then enter
DESCRIBE log.dnodes_info;
to see the schema of thednodes_info
supertable. - Finally, you can enter
SELECT LAST_ROW(*) FROM log.dnodes_info GROUP BY dnode_id;
to see the latest data point for eachdnode_id
. - You can also use DBeaver to write data to your TDengine databases.
If the preceding statements executed successfully, this indicated that the connection between DBeaver and TDengine is working properly. With DBeaver, you can use a variety of features, including SQL scripts, with your TDengine deployment.
If you have any difficulties in using TDengine or recommendations for improvement, get in touch with us on GitHub or Discord.