Skip to main content

Client Libraries

TDengine provides a rich set of application development interfaces. To facilitate users in quickly developing their own applications, TDengine supports connectors for multiple programming languages, including official connectors for C/C++, Java, Python, Go, Node.js, C#, and Rust. These connectors support connecting to the TDengine cluster using the native interface (taosc) and WebSocket interface. Community developers have also contributed several unofficial connectors, such as the ADO.NET connector, Lua connector, and PHP connector.

Figure 1. TDengine client library architecture

Supported Platforms

Currently, the native interface connectors for TDengine support platforms including: X64/ARM64 hardware platforms, as well as Linux/Win64 development environments. The compatibility matrix is as follows:

CPUOSJavaPythonGoNode.jsC#RustC/C++
X86 64bitLinux
X86 64bitWin64
X86 64bitmacOS
ARM64Linux
ARM64macOS

Where ● indicates official testing and verification passed, ○ indicates unofficial testing and verification passed, -- indicates unverified.

Using REST connections can support a wider range of operating systems as they do not depend on client drivers.

Version Support

TDengine version updates often add new features. The list below shows the best matching connector versions for each TDengine version.

TDengine VersionJavaPythonGoC#Node.jsRustC/C++
3.3.0.0 and above3.3.0 and abovetaospy 2.7.15 and above, taos-ws-py 0.3.2 and above3.5.5 and above3.1.3 and above3.1.0 and aboveCurrent versionSame as TDengine version
3.0.0.0 and above3.0.2 and aboveCurrent version3.0 branch3.0.03.1.0Current versionSame as TDengine version
2.4.0.14 and above2.0.38Current versiondevelop branch1.0.2 - 1.0.62.0.10 - 2.0.12Current versionSame as TDengine version
2.4.0.4 - 2.4.0.132.0.37Current versiondevelop branch1.0.2 - 1.0.62.0.10 - 2.0.12Current versionSame as TDengine version
2.2.x.x2.0.36Current versionmaster branchn/a2.0.7 - 2.0.9Current versionSame as TDengine version
2.0.x.x2.0.34Current versionmaster branchn/a2.0.1 - 2.0.6Current versionSame as TDengine version

Feature Support

The following table compares the support for TDengine features by the connector:

Using Native Interface (taosc)

FeatureJavaPythonGoC#RustC/C++
Connection ManagementSupportedSupportedSupportedSupportedSupportedSupported
Execute SQLSupportedSupportedSupportedSupportedSupportedSupported
Parameter BindingSupportedSupportedSupportedSupportedSupportedSupported
Data Subscription (TMQ)SupportedSupportedSupportedSupportedSupportedSupported
Schema-less WriteSupportedSupportedSupportedSupportedSupportedSupported
info

Due to different database framework specifications in various programming languages, it does not imply that all C/C++ interfaces need corresponding encapsulation support.

Using HTTP REST Interface

FeatureJavaPythonGo
Connection ManagementSupportedSupportedSupported
Execute SQLSupportedSupportedSupported

Using WebSocket Interface

FeatureJavaPythonGoC#Node.jsRustC/C++
Connection ManagementSupportedSupportedSupportedSupportedSupportedSupportedSupported
Execute SQLSupportedSupportedSupportedSupportedSupportedSupportedSupported
Parameter BindingSupportedSupportedSupportedSupportedSupportedSupportedSupported
Data Subscription (TMQ)SupportedSupportedSupportedSupportedSupportedSupportedSupported
Schema-less WriteSupportedSupportedSupportedSupportedSupportedSupportedSupported
warning
  • Regardless of the programming language connector chosen, it is recommended for database applications using TDengine version 2.0 and above to establish an independent connection for each thread, or to establish a connection pool based on threads, to avoid interference of the "USE statement" state variable among threads (however, the connection's query and write operations are thread-safe).

Install Client Driver

info

You only need to install the client driver if you are using a native interface connector on a system where the TDengine server software is not installed.

Installation Steps

  1. Download the client installation package
    1. Unzip the software package

      Place the package in any directory where the current user has read and write access, then execute the following command: tar -xzvf TDengine-client-VERSION.tar.gz Replace VERSION with the actual version string.

    2. Run the installation script

      After unzipping the package, you will see the following files (directories) in the unzipped directory:

      • install_client.sh: Installation script, used for applying the driver
      • package.tar.gz: Application driver installation package
      • driver: TDengine application driver
      • examples: Sample programs for various programming languages (c/C#/go/JDBC/MATLAB/python/R) Run install_client.sh to install.
    3. Configure taos.cfg

      Edit the taos.cfg file (default path /etc/taos/taos.cfg), change firstEP to the End Point of the TDengine server, for example: h1.tdengine.com:6030

    tip
    1. If the TDengine service is not deployed on this machine and only the application driver is installed, then only firstEP needs to be configured in taos.cfg, there is no need to configure FQDN on this machine.
    2. To prevent the "Unable to resolve FQDN" error when connecting to the server, it is recommended to ensure that the /etc/hosts file on your machine is configured with the correct FQDN value of the server, or that the DNS service is properly configured.

    Installation Verification

    After completing the above installation and configuration, and confirming that the TDengine service has started running normally, you can now use the TDengine CLI tool to log in.

    In the Linux shell, execute taos directly to connect to the TDengine service, entering the TDengine CLI interface, as shown below:

    $ taos

    taos> show databases;
    name |
    =================================
    information_schema |
    performance_schema |
    db |
    Query OK, 3 rows in database (0.019154s)

    taos>

    📄️ C/C++

    C/C++ developers can use the TDengine client driver, i.e., the C/C++ connector (hereinafter referred to as the TDengine client driver), to develop their own applications to connect to the TDengine cluster for data storage, querying, and other functionalities. The API of the TDengine client driver is similar to MySQL's C API. When using the application, it is necessary to include the TDengine header file, which lists the function prototypes of the provided APIs; the application also needs to link to the corresponding dynamic library on the platform.