Using DBeaver in your TDengine deployment

Shuduo Sang
Shuduo Sang
/

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:

  1. Download the TDengine JDBC driver.
    1. In a Web browser, open the Maven Central Repository Search page.
    2. Search for com.taosdata.jdbc and click the Download icon.
    3. Select the dist.jar format and save the file to your local machine.
  2. Download and install the DBeaver package from the official website.
  3. Once installation is complete, open DBeaver. From the main menu, select Database > Driver Manager and click New.
    TDengine time series database | 22.054 01 driver
  4. 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.
    TDengine time series database | 22.054 02 create
  5. At the bottom of the window, click Find Class. Then, select com.taosdata.jdbc.rs.RestfulDriver in the Driver class field.
    TDengine time series database | 22.054 03 class
  6. 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>
    TDengine time series database | 22.054 04 settings
  7. Select Database > New Database Connection, open the All tab, and search for the driver that you created. Click Next.
    TDengine time series database | 22.054 05 connection
  8. Enter the URL for your TDengine deployment and click Test Connection.
    TDengine time series database | 22.054 06 test

Verification

  1. 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.
    TDengine time series database | 22.054 07 navigator
  2. 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.
  3. As an example, you can enter SHOW log.stables; to display all supertables in the default log database. TDengine time series database | 22.054 08
  4. You can then enter DESCRIBE log.dnodes_info; to see the schema of the dnodes_info supertable.
  5. Finally, you can enter SELECT LAST_ROW(*) FROM log.dnodes_info GROUP BY dnode_id; to see the latest data point for each dnode_id.
  6. 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.

Author

  • Shuduo Sang
    Shuduo Sang

    Shuduo Sang is an open-source software veteran at TDengine, working on magnifying TDengine capabilities to connect easily with more third-party software for IoT and DevOps users. He and his team develop and maintain the multiple programming language connectors and tools for TDengine such as taosBenchmark and taosAdapter. Before joining TDengine, he worked on open-source and Linux at Canonical and Intel.