Merge pull request #29194 from taosdata/3.0

3.0
This commit is contained in:
dongming chen 2024-12-18 08:33:58 +08:00 committed by GitHub
commit 69980ac5a8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
166 changed files with 7178 additions and 1897 deletions

View File

@ -2,7 +2,7 @@
# taosadapter
ExternalProject_Add(taosadapter
GIT_REPOSITORY https://github.com/taosdata/taosadapter.git
GIT_TAG main
GIT_TAG 3.0
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taosadapter"
BINARY_DIR ""
#BUILD_IN_SOURCE TRUE

View File

@ -2,7 +2,7 @@
# taos-tools
ExternalProject_Add(taos-tools
GIT_REPOSITORY https://github.com/taosdata/taos-tools.git
GIT_TAG main
GIT_TAG 3.0
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taos-tools"
BINARY_DIR ""
#BUILD_IN_SOURCE TRUE

View File

@ -2,7 +2,7 @@
# taosws-rs
ExternalProject_Add(taosws-rs
GIT_REPOSITORY https://github.com/taosdata/taos-connector-rust.git
GIT_TAG main
GIT_TAG 3.0
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taosws-rs"
BINARY_DIR ""
#BUILD_IN_SOURCE TRUE

View File

@ -7,19 +7,19 @@ import Tabs from "@theme/Tabs";
import TabItem from "@theme/TabItem";
import Image from '@theme/IdealImage';
import imgConnect from '../assets/connecting-to-tdengine-01.png';
import ConnJava from "./_connect_java.mdx";
import ConnGo from "./_connect_go.mdx";
import ConnRust from "./_connect_rust.mdx";
import ConnNode from "./_connect_node.mdx";
import ConnPythonNative from "./_connect_python.mdx";
import ConnCSNative from "./_connect_cs.mdx";
import ConnC from "./_connect_c.mdx";
import InstallOnLinux from "../14-reference/05-connector/_linux_install.mdx";
import InstallOnWindows from "../14-reference/05-connector/_windows_install.mdx";
import InstallOnMacOS from "../14-reference/05-connector/_macos_install.mdx";
import VerifyLinux from "../14-reference/05-connector/_verify_linux.mdx";
import VerifyMacOS from "../14-reference/05-connector/_verify_macos.mdx";
import VerifyWindows from "../14-reference/05-connector/_verify_windows.mdx";
import ConnJava from "../assets/resources/_connect_java.mdx";
import ConnGo from "../assets/resources/_connect_go.mdx";
import ConnRust from "../assets/resources/_connect_rust.mdx";
import ConnNode from "../assets/resources/_connect_node.mdx";
import ConnPythonNative from "../assets/resources/_connect_python.mdx";
import ConnCSNative from "../assets/resources/_connect_cs.mdx";
import ConnC from "../assets/resources/_connect_c.mdx";
import InstallOnLinux from "../assets/resources/_linux_install.mdx";
import InstallOnWindows from "../assets/resources/_windows_install.mdx";
import InstallOnMacOS from "../assets/resources/_macos_install.mdx";
import VerifyLinux from "../assets/resources/_verify_linux.mdx";
import VerifyMacOS from "../assets/resources/_verify_macos.mdx";
import VerifyWindows from "../assets/resources/_verify_windows.mdx";
TDengine provides a rich set of application development interfaces. To facilitate users in quickly developing their applications, TDengine supports connectors for multiple programming languages. The official connectors include support for C/C++, Java, Python, Go, Node.js, C#, Rust, Lua (community contribution), and PHP (community contribution). These connectors support connecting to the TDengine cluster using the native interface (taosc) and REST interface (not supported in some languages yet). Community developers have also contributed several unofficial connectors, such as ADO.NET connector, Lua connector, and PHP connector. Additionally, TDengine can directly call the REST API provided by taosadapter for data writing and querying operations.

View File

@ -3,7 +3,7 @@ title: Prometheus
slug: /third-party-tools/data-collection/prometheus
---
import Prometheus from "./_prometheus.mdx"
import Prometheus from "../../assets/resources/_prometheus.mdx"
Prometheus is a popular open-source monitoring and alerting system. In 2016, Prometheus joined the Cloud Native Computing Foundation (CNCF), becoming the second hosted project after Kubernetes. The project has a very active developer and user community.

View File

@ -3,7 +3,7 @@ title: Telegraf
slug: /third-party-tools/data-collection/telegraf
---
import Telegraf from "./_telegraf.mdx"
import Telegraf from "../../assets/resources/_telegraf.mdx"
Telegraf is a very popular open-source metric collection software. In data collection and platform monitoring systems, Telegraf can collect operational information from various components without the need to manually write scripts for periodic collection, reducing the difficulty of data acquisition.

View File

@ -3,7 +3,7 @@ title: collectd
slug: /third-party-tools/data-collection/collectd
---
import CollectD from "./_collectd.mdx"
import CollectD from "../../assets/resources/_collectd.mdx"
collectd is a daemon for collecting system performance. collectd provides various storage mechanisms to store different values. It periodically collects relevant statistical information about the system while it is running and storing information. Utilizing this information helps identify current system performance bottlenecks and predict future system loads.

View File

@ -3,7 +3,7 @@ title: StatsD
slug: /third-party-tools/data-collection/statsd
---
import StatsD from "./_statsd.mdx"
import StatsD from "../../assets/resources/_statsd.mdx"
StatsD is a simple daemon for aggregating and summarizing application metrics that has rapidly evolved in recent years into a unified protocol for collecting application performance metrics.

View File

@ -3,7 +3,7 @@ title: Icinga2
slug: /third-party-tools/data-collection/icinga2
---
import Icinga2 from "./_icinga2.mdx"
import Icinga2 from "../../assets/resources/_icinga2.mdx"
icinga2 is an open-source host and network monitoring software, originally developed from the Nagios network monitoring application. Currently, icinga2 is released under the GNU GPL v2 license.

View File

@ -3,7 +3,7 @@ title: TCollector
slug: /third-party-tools/data-collection/tcollector
---
import TCollector from "./_tcollector.mdx"
import TCollector from "../../assets/resources/_tcollector.mdx"
TCollector is part of openTSDB, used for collecting client logs and sending them to the database.

View File

@ -0,0 +1,76 @@
---
sidebar_label: Superset
title: Integration With Superset
toc_max_heading_level: 4
---
Apache Superset is a modern enterprise level business intelligence (BI) web application primarily used for data exploration and visualization.
It is supported by the Apache Software Foundation and is an open source project with an active community and rich ecosystem.
Apache Superset provides an intuitive user interface that makes creating, sharing, and visualizing data simple, while supporting multiple data sources and rich visualization options.
Through the Python connector of TDengine, Superset can support TDengine data sources and provide functions such as data presentation and analysis
## Install Apache Superset
Ensure that Apache Superset v2.1.0 or above is installed. If not, please visit [official website](https://superset.apache.org/) to install
## Install TDengine
Both TDengine Enterprise Edition and Community Edition are supported, with version requirements of 3.0 or higher
## Install TDengine Python Connector
The Python connector of TDengine comes with a connection driver that supports Superset in versions 2.1.18 and later, which will be automatically installed in the Superset directory and provide data source services.
The connection uses the WebSocket protocol, so it is necessary to install the `taos-ws-py` component of TDengine separately. The complete installation script is as follows:
```bash
pip3 install taospy
pip3 install taos-ws-py
```
## Configure TDengine Connection In Superset
**Step 1**, enter the new database connection page, "Superset" → "Setting" → "Database Connections" → "+DATABASE"
**Step 2**, select TDengine database connection, select the "TDengine" option from the drop-down list of "SUPPORTED DATABASES".
:::tip
If there is no TDengine option in the drop-down list, please confirm that the steps of installing, `Superset` is first and `Python Connector` is second.
:::
**Step 3**, write a name of connection in "DISPLAY NAME"
**Step 4**, The "SQLALCHEMY URL" field is a key connection information string, and it must be filled in correctly
```bash
taosws://user:password@host:port
```
| Parameter | <center>Parameter Description</center> |
|:---------- |:--------------------------------------------------------- |
|user | Username for logging into TDengine database |
|password | Password for logging into TDengine database |
|host | Name of the host where the TDengine database is located |
|port | The port that provides WebSocket services, default is 6041 |
Example:
The TDengine database installed on this machine provides WebSocket service port 6041, using the default username and password, "SQLALCHEMY URL" is:
```bash
taosws://root:taosdata@localhost:6041
```
**Step 5**, configure the connection string, click "TEST CONNECTION" to test if the connection can be successful. After passing the test, click the "CONNECT" button to complete the connection
## Start
There is no difference in the use of TDengine data source compared to other data sources. Here is a brief introduction to basic data queries:
1. Click the "+" button in the upper right corner of the Superset interface, select "SQL query", and enter the query interface
2. Select the "TDengine" data source that has been created earlier from the dropdown list of "DATABASES" in the upper left corner
3. Select the name of the database to be operated on from the drop-down list of "SCHEMA" (system libraries are not displayed)
4. "SEE TABLE SCHEMA" select the name of the super table or regular table to be operated on (sub tables are not displayed)
5. Subsequently, the schema information of the selected table will be displayed in the following area
6. In the SQL editor area, any SQL statement that conforms to TDengine syntax can be entered for execution
## Example
We chose two popular templates from the Superset Chart template to showcase their effects, using smart meter data as an example:
1. "Aggregate" Type, which displays the maximum voltage value collected per minute during the specified time period in Group 4
![superset-demo1](./superset-demo1.jpeg)
2. "RAW RECORDS" Type, which displays the collected values of current and voltage during the specified time period in Group 4
![superset-demo2](./superset-demo2.jpeg)

Binary file not shown.

After

Width:  |  Height:  |  Size: 650 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 784 KiB

View File

@ -62,7 +62,7 @@ After modifying configuration file parameters, you need to restart the *taosd* s
|telemetryReporting | |Supported, effective immediately |Whether to upload telemetry, 0: do not upload, 1: upload, default value 1|
|telemetryServer | |Not supported |Telemetry server address|
|telemetryPort | |Not supported |Telemetry server port number|
|telemetryInterval | |Supported, effective immediately |Telemetry upload interval, in seconds, default 43200|
|telemetryInterval | |Supported, effective immediately |Telemetry upload interval, in seconds, default 86400|
|crashReporting | |Supported, effective immediately |Whether to upload crash information; 0: do not upload, 1: upload; default value 1|
### Query Related

View File

@ -6,11 +6,11 @@ slug: /tdengine-reference/components/taosadapter
import Image from '@theme/IdealImage';
import imgAdapter from '../../assets/taosadapter-01.png';
import Prometheus from "../../10-third-party/01-collection/_prometheus.mdx"
import CollectD from "../../10-third-party/01-collection/_collectd.mdx"
import StatsD from "../../10-third-party/01-collection/_statsd.mdx"
import Icinga2 from "../../10-third-party/01-collection/_icinga2.mdx"
import TCollector from "../../10-third-party/01-collection/_tcollector.mdx"
import Prometheus from "../../assets/resources/_prometheus.mdx"
import CollectD from "../../assets/resources/_collectd.mdx"
import StatsD from "../../assets/resources/_statsd.mdx"
import Icinga2 from "../../assets/resources/_icinga2.mdx"
import TCollector from "../../assets/resources/_tcollector.mdx"
taosAdapter is a companion tool for TDengine, serving as a bridge and adapter between the TDengine cluster and applications. It provides an easy and efficient way to ingest data directly from data collection agents (such as Telegraf, StatsD, collectd, etc.). It also offers InfluxDB/OpenTSDB compatible data ingestion interfaces, allowing InfluxDB/OpenTSDB applications to be seamlessly ported to TDengine.

View File

@ -35,9 +35,9 @@ Please refer to the [Supported Platforms List](../#supported-platforms)
### Version History
| TDengine Client Version | Main Changes | TDengine Version |
| :------------------: | :---------------------------: | :----------------: |
| 3.3.3.0 | First release, providing comprehensive support for SQL execution, parameter binding, schema-less writing, and data subscription. | 3.3.2.0 and higher versions |
| TDengine Client Version | Major Changes | TDengine Version |
| ------------------ | --------------------------- | ---------------- |
| 3.3.3.0 | First release, providing comprehensive support for SQL execution, parameter binding, schema-less writing, and data subscription. | 3.3.2.0 and higher |
### Error Codes

View File

@ -6,7 +6,7 @@ slug: /tdengine-reference/client-libraries/java
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import RequestId from "./_request_id.mdx";
import RequestId from "../../assets/resources/_request_id.mdx";
`taos-jdbcdriver` is the official Java connector for TDengine, allowing Java developers to develop applications that access the TDengine database. `taos-jdbcdriver` implements the interfaces of the JDBC driver standard.
@ -18,45 +18,45 @@ The JDBC driver implementation for TDengine strives to be consistent with relati
:::
## JDBC and JRE Compatibility
## JDBC and JRE Version Compatibility
- JDBC: Supports JDBC 4.2, with some features like schemaless writing and data subscription provided separately
- JRE: Supports JRE 8 and above
- JDBC: Supports JDBC 4.2 and above.
- JRE: Supports JRE 8 and above.
## Supported Platforms
Native connection supports the same platforms as the TDengine client driver.
REST connection supports all platforms that can run Java.
- Native connection supports the same platforms as the TDengine client driver.
- WebSocket/REST connection supports all platforms that can run Java.
## Version History
| taos-jdbcdriver Version | Main Changes | TDengine Version |
| :------------------: | :----------------------------------------------------------------------------------------------------------------------------------------------------: | :----------------: |
| 3.4.0 | 1. Replaced fastjson library with jackson; 2. WebSocket uses a separate protocol identifier; 3. Optimized background thread usage to avoid user misuse leading to timeouts. | - |
| 3.3.4 | 1. Fixed getInt error when data type is float | - |
| 3.3.3 | 1. Fixed memory leak caused by closing WebSocket statement | - |
| 3.3.2 | 1. Optimized parameter binding performance under WebSocket connection; 2. Improved support for mybatis | - |
| 3.3.0 | 1. Optimized data transmission performance under WebSocket connection; 2. Supports skipping SSL verification, off by default | 3.3.2.0 and higher |
| 3.2.11 | Fixed a bug in closing result set in Native connection | - |
| 3.2.10 | 1. REST/WebSocket connections support data compression during transmission; 2. WebSocket automatic reconnection mechanism, off by default; 3. Connection class provides methods for schemaless writing; 4. Optimized data fetching performance for native connections; 5. Fixed some known issues; 6. Metadata retrieval functions can return a list of supported functions. | - |
| 3.2.9 | Fixed bug in closing WebSocket prepareStatement | - |
| 3.2.8 | Optimized auto-commit, fixed manual commit bug in WebSocket, optimized WebSocket prepareStatement using a single connection, metadata supports views | - |
| 3.2.7 | Supports VARBINARY and GEOMETRY types, added timezone setting support for native connections. Added WebSocket automatic reconnection feature. | 3.2.0.0 and higher |
| 3.2.5 | Data subscription adds committed() and assignment() methods | 3.1.0.3 and higher |
| 3.2.4 | Data subscription adds enable.auto.commit parameter under WebSocket connection, as well as unsubscribe() method. | - |
| 3.2.3 | Fixed ResultSet data parsing failure in some cases | - |
| 3.2.2 | New feature: Data subscription supports seek function. | 3.0.5.0 and higher |
| 3.2.1 | New feature: WebSocket connection supports schemaless and prepareStatement writing. Change: consumer poll returns result set as ConsumerRecord, which can be accessed through value() method. | 3.0.3.0 and higher |
| 3.2.0 | Connection issues, not recommended for use | - |
| 3.1.0 | WebSocket connection supports subscription function | - |
| 3.0.1 - 3.0.4 | Fixed data parsing errors in result sets under some conditions. 3.0.1 compiled in JDK 11 environment, other versions recommended for JDK 8 | - |
| 3.0.0 | Supports TDengine 3.0 | 3.0.0.0 and higher |
| 2.0.42 | Fixed wasNull interface return value in WebSocket connection | - |
| 2.0.41 | Fixed username and password encoding method in REST connection | - |
| 2.0.39 - 2.0.40 | Added REST connection/request timeout settings | - |
| 2.0.38 | JDBC REST connection adds batch fetching function | - |
| 2.0.37 | Added support for json tag | - |
| 2.0.36 | Added support for schemaless writing | - |
| taos-jdbcdriver Version | Major Changes | TDengine Version |
| ------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------- |
| 3.4.0 | 1. Replaced fastjson library with jackson. <br/> 2. WebSocket uses a separate protocol identifier. <br/> 3. Optimized background thread usage to avoid user misuse leading to timeouts. | - |
| 3.3.4 | Fixed getInt error when data type is float. | - |
| 3.3.3 | Fixed memory leak caused by closing WebSocket statement. | - |
| 3.3.2 | 1. Optimized parameter binding performance under WebSocket connection. <br/> 2. Improved support for mybatis. | - |
| 3.3.0 | 1. Optimized data transmission performance under WebSocket connection. <br/> 2. Supports skipping SSL verification, off by default. | 3.3.2.0 and higher |
| 3.2.11 | Fixed a bug in closing result set in Native connection. | - |
| 3.2.10 | 1. REST/WebSocket connections support data compression during transmission. <br/> 2. WebSocket automatic reconnection mechanism, off by default. <br/> 3. Connection class provides methods for schemaless writing. <br/> 4. Optimized data fetching performance for native connections. <br/> 5. Fixed some known issues. <br/> 6. Metadata retrieval functions can return a list of supported functions. | - |
| 3.2.9 | Fixed bug in closing WebSocket prepareStatement. | - |
| 3.2.8 | 1. Optimized auto-commit. <br/> 2. Fixed manual commit bug in WebSocket. <br/> 3. Optimized WebSocket prepareStatement using a single connection. <br/> 4. Metadata supports views. | - |
| 3.2.7 | 1. Supports VARBINARY and GEOMETRY types. <br/> 2. Added timezone setting support for native connections. <br/> 3. Added WebSocket automatic reconnection feature. | 3.2.0.0 and higher |
| 3.2.5 | Data subscription adds committed() and assignment() methods. | 3.1.0.3 and higher |
| 3.2.4 | Data subscription adds enable.auto.commit parameter under WebSocket connection, as well as unsubscribe() method. | - |
| 3.2.3 | Fixed ResultSet data parsing failure in some cases. | - |
| 3.2.2 | New feature: Data subscription supports seek function. | 3.0.5.0 and higher |
| 3.2.1 | 1. WebSocket connection supports schemaless and prepareStatement writing. <br/> 2. Consumer poll returns result set as ConsumerRecord, which can be accessed through value() method. | 3.0.3.0 and higher |
| 3.2.0 | Connection issues, not recommended for use. | - |
| 3.1.0 | WebSocket connection supports subscription function. | - |
| 3.0.1 - 3.0.4 | Fixed data parsing errors in result sets under some conditions. 3.0.1 compiled in JDK 11 environment, other versions recommended for JDK 8. | - |
| 3.0.0 | Supports TDengine 3.0 | 3.0.0.0 and higher |
| 2.0.42 | Fixed wasNull interface return value in WebSocket connection. | - |
| 2.0.41 | Fixed username and password encoding method in REST connection. | - |
| 2.0.39 - 2.0.40 | Added REST connection/request timeout settings. | - |
| 2.0.38 | JDBC REST connection adds batch fetching function. | - |
| 2.0.37 | Added support for json tag. | - |
| 2.0.36 | Added support for schemaless writing. | - |
## Exceptions and Error Codes

View File

@ -6,24 +6,42 @@ slug: /tdengine-reference/client-libraries/go
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import RequestId from "./_request_id.mdx";
import RequestId from "../../assets/resources/_request_id.mdx";
`driver-go` is the official Go language connector for TDengine, implementing the interface of the Go language [database/sql](https://golang.org/pkg/database/sql/) package. Go developers can use it to develop applications that access data in the TDengine cluster.
## Compatibility
## Go Version Compatibility
Supports a minimum Go version of 1.14, but the latest version of Go is recommended.
Supports Go 1.14 and above.
## Supported Platforms
Native connections support the same platforms as the TDengine client driver.
REST connections support all platforms that can run Go.
- Native connections support the same platforms as the TDengine client driver.
- WebSocket/REST connections support all platforms that can run Go.
## Version Support
## Version History
Please refer to the [version support list](https://github.com/taosdata/driver-go#remind).
| driver-go Version | Major Changes | TDengine Version |
|------------------|------------------------------------------------------------------|-------------------|
| v3.5.8 | Fixed null pointer exception. | - |
| v3.5.7 | taosWS and taosRestful support passing request id. | - |
| v3.5.6 | Improved websocket query and insert performance. | 3.3.2.0 and higher |
| v3.5.5 | Restful supports skipping SSL certificate check. | - |
| v3.5.4 | Compatible with TDengine 3.3.0.0 tmq raw data. | - |
| v3.5.3 | Refactored taosWS. | - |
| v3.5.2 | Websocket compression and optimized tmq subscription performance. | 3.2.3.0 and higher |
| v3.5.1 | Native stmt query and geometry type support. | 3.2.1.0 and higher |
| v3.5.0 | Support tmq get assignment and seek offset. | 3.0.5.0 and higher |
| v3.3.1 | Schemaless protocol insert based on websocket. | 3.0.4.1 and higher |
| v3.1.0 | Provided Kafka-like subscription API. | - |
| v3.0.4 | Added request id related interfaces. | 3.0.2.2 and higher |
| v3.0.3 | Websocket-based statement insert. | - |
| v3.0.2 | Websocket-based data query and insert. | 3.0.1.5 and higher |
| v3.0.1 | Websocket-based message subscription. | - |
| v3.0.0 | Adapted to TDengine 3.0 query and insert. | 3.0.0.0 and higher |
## Handling Exceptions
## Exceptions and Error Codes
If it is a TDengine error, you can obtain the error code and error message as follows.

View File

@ -4,11 +4,11 @@ title: Rust Client Library
slug: /tdengine-reference/client-libraries/rust
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import Tabs from "@theme/Tabs";
import TabItem from "@theme/TabItem";
import Preparation from "./_preparation.mdx"
import RequestId from "./_request_id.mdx";
import Preparation from "../../assets/resources/_preparation.mdx"
import RequestId from "../../assets/resources/_request_id.mdx";
[![Crates.io](https://img.shields.io/crates/v/taos)](https://crates.io/crates/taos) ![Crates.io](https://img.shields.io/crates/d/taos) [![docs.rs](https://img.shields.io/docsrs/taos)](https://docs.rs/taos)
@ -16,37 +16,30 @@ import RequestId from "./_request_id.mdx";
The source code for this Rust connector is hosted on [GitHub](https://github.com/taosdata/taos-connector-rust).
## Connection Methods
## Rust Version Compatibility
`taos` provides two ways to establish a connection. Generally, we recommend using **WebSocket Connection**.
- **Native Connection**, which connects to a TDengine instance via the TDengine client driver (taosc).
- **WebSocket Connection**, which connects to a TDengine instance via the WebSocket interface of taosAdapter.
You can specify which connector to use through different "features (i.e., the Cargo keyword `features`)" (both are supported by default).
For a detailed introduction to connection methods, please refer to: [Connection Methods](../../../developer-guide/connecting-to-tdengine/)
Supports Rust 1.70 and above.
## Supported Platforms
The platforms supported by the native connection are consistent with those supported by the TDengine client driver.
WebSocket connection supports all platforms that can run Rust.
- The platforms supported by the native connection are consistent with those supported by the TDengine client driver.
- WebSocket connection supports all platforms that can run Rust.
## Version History
| Rust Connector Version | TDengine Version | Main Features |
| :----------------: | :--------------: | :--------------------------------------------------: |
| v0.12.3 | 3.3.0.0 or later | Optimized WebSocket query and insertion performance, support for VARBINARY and GEOMETRY types |
| v0.12.0 | 3.2.3.0 or later | WS supports compression. |
| v0.11.0 | 3.2.0.0 | TMQ feature optimization. |
| v0.10.0 | 3.1.0.0 | WS endpoint change. |
| v0.9.2 | 3.0.7.0 | STMT: ws to get tag_fields, col_fields. |
| v0.8.12 | 3.0.5.0 | Message subscription: get consumption progress and start consuming at a specified progress. |
| v0.8.0 | 3.0.4.0 | Supports schema-less writing. |
| v0.7.6 | 3.0.3.0 | Supports using req_id in requests. |
| v0.6.0 | 3.0.0.0 | Basic functionality. |
| Rust Connector Version | Major Changes | TDengine Version |
| ---------------------- | ----------------------------------------------------------------------------------------------------- | ------------------ |
| v0.12.3 | 1. Optimized WebSocket query and insert performance. <br/> 2. Supported VARBINARY and GEOMETRY types. | 3.3.0.0 and higher |
| v0.12.0 | WebSocket supports compression. | 3.2.3.0 and higher |
| v0.11.0 | TMQ feature optimization. | 3.2.0.0 and higher |
| v0.10.0 | WebSocket endpoint change. | 3.1.0.0 and higher |
| v0.9.2 | STMT: WebSocket to get tag_fields, col_fields. | 3.0.7.0 and higher |
| v0.8.12 | Message subscription: get consumption progress and start consuming at a specified progress. | 3.0.5.0 and higher |
| v0.8.0 | Supports schema-less writing. | 3.0.4.0 and higher |
| v0.7.6 | Supports using req_id in requests. | 3.0.3.0 and higher |
| v0.6.0 | Basic functionality. | 3.0.0.0 and higher |
## Error Handling
## Exceptions and Error Codes
After an error occurs, you can obtain detailed information about the error:
@ -81,14 +74,14 @@ TDengine currently supports timestamp, numeric, character, and boolean types, wi
| BINARY | Vec\<u8> |
| NCHAR | String |
| JSON | serde_json::Value |
| VARBINARY | Bytes |
| GEOMETRY | Bytes |
| VARBINARY | Bytes |
| GEOMETRY | Bytes |
**Note**: The JSON type is only supported in tags.
## Summary of Example Programs
For the source code of the example programs, please refer to: [rust example](https://github.com/taosdata/TDengine/tree/main/docs/examples/rust)
Please refer to: [rust example](https://github.com/taosdata/TDengine/tree/main/docs/examples/rust)
## Frequently Asked Questions
@ -97,9 +90,9 @@ Please refer to [FAQ](../../../frequently-asked-questions/)
## API Reference
The Rust connector interfaces are divided into synchronous and asynchronous interfaces, where the synchronous interfaces are generally implemented by the asynchronous ones, and the method signatures are basically the same except for the async keyword. For interfaces where the synchronous and asynchronous functionalities are the same, this document only provides explanations for the synchronous interfaces.
For WebSocket connections and native connections, other than the different DSNs required to establish the connections, there is no difference in calling other interfaces.
For WebSocket connections and native connections, other than the different DSNs required to establish the connections, there is no difference in calling other interfaces.
### Connection Features
### Connection Features
#### DSN
@ -132,26 +125,31 @@ A complete DSN description string example is as follows: `taos+ws://localhost:60
The TaosBuilder struct primarily provides methods for building Taos objects based on DSN, as well as features for checking connections and obtaining the client version number.
- `fn available_params() -> &'static [&'static str]`
- **Interface Description**: Retrieves a list of available parameters in the DSN.
- **Return Value**: Returns a reference to a static slice of strings containing the names of available parameters.
- `fn from_dsn<D: IntoDsn>(dsn: D) -> RawResult<Self>`
- **Interface Description**: Creates a connection using a DSN string without checking the connection.
- **Parameter Description**:
- `dsn`: DSN string or a type that can be converted into a DSN.
- **Return Value**: On success, returns a `RawResult` of its own type; on failure, returns an error.
- `fn client_version() -> &'static str`
- **Interface Description**: Gets the client version.
- **Return Value**: Returns a static string of the client version.
- `fn ping(&self, _: &mut Self::Target) -> RawResult<()>`
- **Interface Description**: Checks if the connection is still alive.
- **Parameter Description**:
- `_`: Mutable reference to the target connection.
- **Return Value**: On success, returns an empty `RawResult`; on failure, returns an error.
- `fn ready(&self) -> bool`
- **Interface Description**: Checks if it is ready to connect.
- **Return Value**: Mostly returns `true`, indicating the address is ready for connection.
@ -168,20 +166,24 @@ Executing SQL primarily uses the Taos struct, and obtaining the result set and m
The Taos struct provides multiple database operation APIs, including: executing SQL, schema-less writing, and some common database query encapsulations (such as creating databases, fetching)
- `pub fn is_native(&self) -> bool`
- **Interface Description**: Determines if the connection uses a native protocol.
- **Return Value**: Returns `true` if using a native protocol, otherwise returns `false`.
- `pub fn is_ws(&self) -> bool`
- **Interface Description**: Determines if the connection uses the WebSocket protocol.
- **Return Value**: Returns `true` if using the WebSocket protocol, otherwise returns `false`.
- `fn query<T: AsRef<str>>(&self, sql: T) -> RawResult<Self::ResultSet>`
- **Interface Description**: Executes an SQL query.
- **Parameter Description**:
- `sql`: The SQL statement to execute.
- **Return Value**: On success, returns a `RawResult` of the `ResultSet`; on failure, returns an error.
- `fn query_with_req_id<T: AsRef<str>>(&self, sql: T, req_id: u64) -> RawResult<Self::ResultSet>`
- **Interface Description**: Executes an SQL query with a request ID.
- **Parameter Description**:
- `sql`: The SQL statement to execute.
@ -189,28 +191,33 @@ The Taos struct provides multiple database operation APIs, including: executing
- **Return Value**: On success, returns a `RawResult` of the `ResultSet`; on failure, returns an error.
- `fn exec<T: AsRef<str>>(&self, sql: T) -> RawResult<usize>`
- **Interface Description**: Executes an SQL statement.
- **Parameter Description**:
- `sql`: The SQL statement to execute.
- **Return Value**: On success, returns the number of affected rows; on failure, returns an error.
- `fn exec_many<T: AsRef<str>, I: IntoIterator<Item = T>>(&self, input: I) -> RawResult<usize>`
- **Interface Description**: Executes multiple SQL statements in batch.
- **Parameter Description**:
- `input`: Collection of SQL statements to execute.
- **Return Value**: On success, returns the total number of affected rows; on failure, returns an error.
- `fn query_one<T: AsRef<str>, O: DeserializeOwned>(&self, sql: T) -> RawResult<Option<O>>`
- **Interface Description**: Executes an SQL query and returns a single result.
- **Parameter Description**:
- `sql`: The SQL statement to execute.
- **Return Value**: On success, returns an optional result object; on failure, returns an error.
- `fn server_version(&self) -> RawResult<Cow<str>>`
- **Interface Description**: Gets the server version.
- **Return Value**: On success, returns the server version string as a `RawResult`; on failure, returns an error.
- `fn create_topic(&self, name: impl AsRef<str>, sql: impl AsRef<str>) -> RawResult<()>`
- **Interface Description**: Creates a topic.
- **Parameter Description**:
- `name`: The name of the topic.
@ -218,20 +225,24 @@ The Taos struct provides multiple database operation APIs, including: executing
- **Return Value**: On success, returns an empty `RawResult`; on failure, returns an error.
- `fn databases(&self) -> RawResult<Vec<ShowDatabase>>`
- **Interface Description**: Retrieves a list of databases.
- **Return Value**: On success, returns a list of databases as a `RawResult`; on failure, returns an error.
- `fn topics(&self) -> RawResult<Vec<Topic>>`
- **Interface Description**: Retrieves topic information.
- **Return Value**: On success, returns a list of topics as a `RawResult`; on failure, returns an error.
- `fn describe(&self, table: &str) -> RawResult<Describe>`
- **Interface Description**: Describes the table structure.
- **Parameter Description**:
- `table`: The name of the table.
- **Return Value**: On success, returns a description of the table structure as a `RawResult`; on failure, returns an error.
- `fn database_exists(&self, name: &str) -> RawResult<bool>`
- **Interface Description**: Checks if a database exists.
- **Parameter Description**:
- `name`: The name of the database.
@ -243,11 +254,12 @@ The Taos struct provides multiple database operation APIs, including: executing
- `data`: Schema-less data.
- **Return Value**: On success, returns an empty `RawResult`; on failure, returns an error.
### SmlData
### SmlData
The SmlData structure provides a data structure for schema-less writing and methods for accessing properties.
- `pub struct SmlData`
- **Structure Description**: The `SmlData` structure is used to store schema-less data and related information.
- **Field Description**:
- `protocol`: Schema-less protocol, supports InfluxDB `Line`, OpenTSDB `Telnet`, OpenTSDB `Json`.
@ -257,18 +269,22 @@ The SmlData structure provides a data structure for schema-less writing and meth
- `req_id`: Request ID.
- `pub fn protocol(&self) -> SchemalessProtocol`
- **Interface Description**: Gets the schema-less protocol.
- **Return Value**: Schema-less protocol type, supports InfluxDB `Line`, OpenTSDB `Telnet`, OpenTSDB `Json`.
- `pub fn precision(&self) -> SchemalessPrecision`
- **Interface Description**: Gets the timestamp precision.
- **Return Value**: Timestamp precision type, supports `Hours`, `Minutes`, `Seconds`, `Millisecond` (default), `Microsecond`, `Nanosecond`.
- `pub fn data(&self) -> &Vec<String>`
- **Interface Description**: Retrieves the list of data.
- **Return Value**: Reference to the list of data.
- `pub fn ttl(&self) -> Option<i32>`
- **Interface Description**: Get the data time-to-live.
- **Return Value**: Time-to-live of the data (optional), in seconds.
@ -276,41 +292,49 @@ The SmlData structure provides a data structure for schema-less writing and meth
- **Interface Description**: Get the request ID.
- **Return Value**: Request ID (optional).
### Result Retrieval
### Result Retrieval
#### ResultSet
The ResultSet structure provides methods for accessing the data and metadata of the result set.
- `fn affected_rows(&self) -> i32`
- **Interface Description**: Get the number of affected rows.
- **Return Value**: Number of affected rows, type `i32`.
- `fn precision(&self) -> Precision`
- **Interface Description**: Get precision information.
- **Return Value**: Precision information, type `Precision`.
- `fn fields(&self) -> &[Field]`
- **Interface Description**: Get field information. See the Field structure description below.
- **Return Value**: Reference to an array of field information.
- `fn summary(&self) -> (usize, usize)`
- **Interface Description**: Get summary information.
- **Return Value**: A tuple containing two `usize` types, representing some statistical information.
- `fn num_of_fields(&self) -> usize`
- **Interface Description**: Get the number of fields.
- **Return Value**: Number of fields, type `usize`.
- `fn blocks(&mut self) -> IBlockIter<'_, Self>`
- **Interface Description**: Get an iterator for the raw data blocks.
- **Return Value**: Iterator for the raw data blocks, type `IBlockIter<'_, Self>`.
- `fn rows(&mut self) -> IRowsIter<'_, Self>`
- **Interface Description**: Get an iterator for row-wise querying.
- **Return Value**: Iterator for row-wise querying, type `IRowsIter<'_, Self>`.
- `fn deserialize<T>(&mut self) -> Map<IRowsIter<'_, Self>, fn(_: Result<RowView<'_>, Error>) -> Result<T, Error>>`
- **Interface Description**: Deserialize row data.
- **Generic Parameters**:
- `T`: Target type, must implement `DeserializeOwned`.
@ -320,15 +344,17 @@ The ResultSet structure provides methods for accessing the data and metadata of
- **Interface Description**: Convert the result set into a two-dimensional vector of values.
- **Return Value**: On success, returns a two-dimensional vector of values, on failure returns an error, type `Result<Vec<Vec<Value>>, Error>`.
#### Field
#### Field
The Field structure provides methods for accessing field information.
- `pub const fn empty() -> Field`
- **Interface Description**: Create an empty `Field` instance.
- **Return Value**: Returns an empty `Field` instance.
- `pub fn new(name: impl Into<String>, ty: Ty, bytes: u32) -> Field`
- **Interface Description**: Create a new `Field` instance.
- **Parameter Description**:
- `name`: Field name.
@ -337,22 +363,27 @@ The Field structure provides methods for accessing field information.
- **Return Value**: Returns a new `Field` instance.
- `pub fn name(&self) -> &str`
- **Interface Description**: Get the field name.
- **Return Value**: Returns the field name.
- `pub fn escaped_name(&self) -> String`
- **Interface Description**: Get the escaped field name.
- **Return Value**: Returns the escaped field name.
- `pub const fn ty(&self) -> Ty`
- **Interface Description**: Get the field type.
- **Return Value**: Returns the field type.
- `pub const fn bytes(&self) -> u32`
- **Interface Description**: Get the preset length of the field.
- **Return Value**: For variable-length data types, returns the preset length; for other types, returns the byte width.
- `pub fn to_c_field(&self) -> c_field_t`
- **Interface Description**: Converts a `Field` instance into a C language structure.
- **Return Value**: Returns the field represented by a C language structure.
@ -364,17 +395,19 @@ The Field structure provides methods for accessing field information.
Parameter binding functionality is mainly supported by the Stmt structure.
#### Stmt
#### Stmt
The Stmt structure provides functionality related to parameter binding, used for efficient writing.
- `fn init(taos: &Q) -> RawResult<Self>`
- **Interface Description**: Initialize the parameter binding instance.
- **Parameter Description**:
- `taos`: Database connection instance.
- **Return Value**: On success, returns the initialized instance; on failure, returns an error.
- `fn init_with_req_id(taos: &Q, req_id: u64) -> RawResult<Self>`
- **Interface Description**: Initialize the parameter binding instance using a request ID.
- **Parameter Description**:
- `taos`: Database connection instance.
@ -382,24 +415,28 @@ The Stmt structure provides functionality related to parameter binding, used for
- **Return Value**: On success, returns the initialized instance; on failure, returns an error.
- `fn prepare<S: AsRef<str>>(&mut self, sql: S) -> RawResult<&mut Self>`
- **Interface Description**: Prepare the SQL statement to be bound.
- **Parameter Description**:
- `sql`: SQL statement to prepare.
- **Return Value**: On success, returns a mutable reference to itself; on failure, returns an error.
- `fn set_tbname<S: AsRef<str>>(&mut self, name: S) -> RawResult<&mut Self>`
- **Interface Description**: Set the table name.
- **Parameter Description**:
- `name`: Table name.
- **Return Value**: On success, returns a mutable reference to itself; on failure, returns an error.
- `fn set_tags(&mut self, tags: &[Value]) -> RawResult<&mut Self>`
- **Interface Description**: Set tags.
- **Parameter Description**:
- `tags`: Array of tags.
- **Return Value**: On success, returns a mutable reference to itself; on failure, returns an error.
- `fn set_tbname_tags<S: AsRef<str>>(&mut self, name: S, tags: &[Value]) -> RawResult<&mut Self>`
- **Interface Description**: Set the table name and tags.
- **Parameter Description**:
- `name`: Table name.
@ -407,16 +444,19 @@ The Stmt structure provides functionality related to parameter binding, used for
- **Return Value**: On success, returns a mutable reference to itself; on failure, returns an error.
- `fn bind(&mut self, params: &[ColumnView]) -> RawResult<&mut Self>`
- **Interface Description**: Bind parameters.
- **Parameter Description**:
- `params`: Array of parameters.
- **Return Value**: On success, returns a mutable reference to itself; on failure, returns an error.
- `fn add_batch(&mut self) -> RawResult<&mut Self>`
- **Interface Description**: Add a batch.
- **Return Value**: On success, returns a mutable reference to itself; on failure, returns an error.
- `fn execute(&mut self) -> RawResult<usize>`
- **Interface Description**: Execute the statement.
- **Return Value**: On success, returns the number of affected rows; on failure, returns an error.
@ -433,26 +473,31 @@ Data subscription mainly involves three structures, providing connection establi
Similar to TaosBuilder, TmqBuilder provides the functionality to create consumer objects.
- `fn available_params() -> &'static [&'static str]`
- **Interface Description**: Get the list of available parameters in the DSN.
- **Return Value**: Returns a reference to a static slice of strings, containing the names of available parameters.
- `fn from_dsn<D: IntoDsn>(dsn: D) -> RawResult<Self>`
- **Interface Description**: Create a connection using a DSN string, without checking the connection.
- **Parameter Description**:
- `dsn`: DSN string or a type that can be converted into DSN.
- **Return Value**: On success, returns `RawResult` of its own type, on failure returns an error.
- `fn client_version() -> &'static str`
- **Interface Description**: Get the client version.
- **Return Value**: Returns a static string of the client version.
- `fn ping(&self, conn: &mut Self::Target) -> RawResult<()>`
- **Interface Description**: Check if the connection is still alive.
- **Parameter Description**:
- `conn`: Mutable reference to the target connection.
- **Return Value**: On success, returns an empty `RawResult`, on failure returns an error.
- `fn ready(&self) -> bool`
- **Interface Description**: Check if it is ready to connect.
- **Return Value**: Mostly returns `true`, indicating that the address is ready to connect.
@ -465,24 +510,28 @@ Similar to TaosBuilder, TmqBuilder provides the functionality to create consumer
The Consumer structure provides subscription-related functionalities, including subscribing, fetching messages, committing offsets, setting offsets, etc.
- `fn subscribe<T: Into<String>, I: IntoIterator<Item = T> + Send>(&mut self, topics: I) -> RawResult<()>`
- **Interface Description**: Subscribe to a series of topics.
- **Parameter Description**:
- `topics`: List of topics to subscribe to.
- **Return Value**: On success, returns an empty `RawResult`, on failure returns an error.
- `fn recv_timeout(&self, timeout: Timeout) -> RawResult<Option<(Self::Offset, MessageSet<Self::Meta, Self::Data>)>>`
- **Interface Description**: Receive messages within a specified timeout period.
- **Parameter Description**:
- `timeout`: Timeout period.
- **Return Value**: On success, returns messages, on failure returns an error.
- `fn commit(&self, offset: Self::Offset) -> RawResult<()>`
- **Interface Description**: Commit the given offset.
- **Parameter Description**:
- `offset`: The offset to commit, see the Offset structure below.
- **Return Value**: On success, returns an empty `RawResult`, on failure returns an error.
- `fn commit_offset(&self, topic_name: &str, vgroup_id: VGroupId, offset: i64) -> RawResult<()>`
- **Interface Description**: Commit offset for a specific topic and partition.
- **Parameter Description**:
- `topic_name`: Topic name.
@ -491,14 +540,17 @@ The Consumer structure provides subscription-related functionalities, including
- **Return Value**: On success, returns an empty `RawResult`, on failure returns an error.
- `fn list_topics(&self) -> RawResult<Vec<String>>`
- **Interface Description**: List all available topics.
- **Return Value**: On success, returns a list of topics, on failure returns an error.
- `fn assignments(&self) -> Option<Vec<(String, Vec<Assignment>)>>`
- **Interface Description**: Get the current assignments of topics and partitions.
- **Return Value**: On success, returns assignment information, on failure returns `None`.
- `fn offset_seek(&mut self, topic: &str, vg_id: VGroupId, offset: i64) -> RawResult<()>`
- **Interface Description**: Set the offset for a specific topic and partition.
- **Parameter Description**:
- `topic`: Topic name.
@ -507,6 +559,7 @@ The Consumer structure provides subscription-related functionalities, including
- **Return Value**: On success, returns an empty `RawResult`, on failure returns an error.
- `fn committed(&self, topic: &str, vgroup_id: VGroupId) -> RawResult<i64>`
- **Interface Description**: Get the committed offset for a specific topic and partition.
- **Parameter Description**:
- `topic`: Topic name.
@ -525,10 +578,12 @@ The Consumer structure provides subscription-related functionalities, including
The Offset structure provides information about the database, topic, and partition to which the current message belongs.
- `fn database(&self) -> &str`
- **Interface Description**: Get the database name of the current message.
- **Return Value**: Reference to the database name.
- `fn topic(&self) -> &str`
- **Interface Description**: Get the topic name of the current message.
- **Return Value**: Reference to the topic name.
@ -536,7 +591,7 @@ The Offset structure provides information about the database, topic, and partiti
- **Interface Description**: Get the partition ID of the current message.
- **Return Value**: Partition ID.
## Appendix
## Appendix
- [Rust connector documentation](https://docs.rs/taos)
- [Rust connector project URL](https://github.com/taosdata/taos-connector-rust)

View File

@ -6,57 +6,73 @@ slug: /tdengine-reference/client-libraries/python
import Tabs from "@theme/Tabs";
import TabItem from "@theme/TabItem";
import RequestId from "./_request_id.mdx";
import RequestId from "../../assets/resources/_request_id.mdx";
`taospy` is the official Python connector for TDengine. `taospy` provides a rich API, making it convenient for Python applications to use TDengine.
`taopsy` is the official connector provided by TDengine database for Python language, which provides multiple access interfaces for database writing, querying, subscribing, etc.
The source code for the Python connector is hosted on [GitHub](https://github.com/taosdata/taos-connector-python).
The installation command is as follows:
``` bash
# Native connection and REST connection
pip3 install taospy
# WebSocket connection, optional installation
pip3 install taos-ws-py
```
The connector code is open sourced and hosted on Github [Taos Connector Python](https://github.com/taosdata/taos-connector-python).
## Connection Methods
`taospy` mainly provides three types of connectors. We generally recommend using **WebSocket Connection**.
`taopsy` provides three connection methods, and we recommend using WebSocket connection.
- **Native Connection**, corresponding to the `taos` module of the `taospy` package. Connects to a TDengine instance natively through the TDengine client driver (taosc), supporting data writing, querying, data subscription, schemaless interface, and parameter binding interface.
- **REST Connection**, corresponding to the `taosrest` module of the `taospy` package. Connects to a TDengine instance through the HTTP interface provided by taosAdapter, does not support schemaless and data subscription features.
- **WebSocket Connection**, corresponding to the `taos-ws-py` package, which is optional. Connects to a TDengine instance through the WebSocket interface provided by taosAdapter, with a feature set slightly different from the native connection.
- **Native Connection**, Python connector loads TDengine client driver (libtaos.so/taos.dll), directly connects to TDengine instance, with high performance and fast speed.
Functionally, it supports functions such as data writing, querying, data subscription, schemaless interface, and parameter binding interface.
- **REST Connection**, The Python connector connects to the TDengine instance through the HTTP interface provided by the taosAdapter, with minimal dependencies and no need to install the TDengine client driver.
Functionality does not support features such as schemaless and data subscription.
- **WebSocket Connection**, The Python connector connects to the TDengine instance through the WebSocket interface provided by the taosAdapter, which combines the advantages of the first two types of connections, namely high performance and low dependency.
In terms of functionality, there are slight differences between the WebSocket connection implementation feature set and native connections.
For a detailed introduction to connection methods, please refer to: [Connection Methods](../../../developer-guide/connecting-to-tdengine/)
For a detailed introduction of the connection method, please refer to: [Connection Method](../../../developer-guide/connecting-to-tdengine/)
In addition to encapsulating the native and REST interfaces, `taospy` also provides a programming interface compliant with [Python Data Access Standard (PEP 249)](https://peps.python.org/pep-0249/). This makes `taospy` easily integrated with many third-party tools, such as [SQLAlchemy](https://www.sqlalchemy.org/) and [pandas](https://pandas.pydata.org/).
In addition to encapsulating Native and REST interfaces, `taopsy` also provides compliance with [the Python Data Access Specification (PEP 249)](https://peps.python.org/pep-0249/) The programming interface.
This makes it easy to integrate `taopsy` with many third-party tools, such as [SQLAlchemy](https://www.sqlalchemy.org/) and [pandas](https://pandas.pydata.org/).
The method of establishing a connection directly with the server using the native interface provided by the client driver is referred to as "Native Connection"; the method of establishing a connection with the server using the REST interface or WebSocket interface provided by taosAdapter is referred to as "REST Connection" or "WebSocket Connection".
The method of establishing a connection directly with the server using the native interface provided by the client driver is referred to as "Native Connection" in the following text;
The method of establishing a connection with the server using the REST interface or WebSocket interface provided by the taosAdapter is referred to as a "REST Connection" or "WebSocket connection" in the following text.
## Python Version Compatibility
Supports Python 3.0 and above.
## Supported Platforms
- Native Connection [Supported Platforms](../../supported-platforms/) are consistent with the platforms supported by the TDengine client.
- REST Connection supports all platforms that can run Python.
-The platforms supported by native connections are consistent with those supported by the TDengine client driver.
-WebSocket/REST connections support all platforms that can run Python.
### Supported Features
## Versions History
- Native Connection supports all core features of TDengine, including: connection management, executing SQL, parameter binding, subscription, schemaless writing.
- REST Connection supports features including: connection management, executing SQL. (Through executing SQL, you can: manage databases, manage tables and supertables, write data, query data, create continuous queries, etc.)
Python Connector historical versions (it is recommended to use the latest version of 'taopsy'):
## Version History
|Python Connector Version | Major Changes | TDengine Version|
| -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------- |
|2.7.18 | Support Apache SuperSet BI Tools. | - |
|2.7.16 | Add subscription configuration (session. timeout. ms, Max. roll. interval. ms). | - |
|2.7.15 | Added support for VARBINRY and GEOMETRY types. | - |
|2.7.14 | Fix Known Issues. | - |
|2.7.13 | Added tmq synchronous submission offset interface. | - |
|2.7.12 | 1. Added support for varbinary type (STMT currently does not support varbinary). <br/> 2 Query performance improvement (thanks to contributor [hadrianl](https://github.com/taosdata/taos-connector-python/pull/209) ). | 3.1.1.2 and higher|
|2.7.9 | Data subscription supports obtaining and resetting consumption progress. | 3.0.2.6 and higher|
|2.7.8 | Added 'executioner_many'. | 3.0.0.0 and higher|
Regardless of the version of TDengine used, it is recommended to use the latest version of `taospy`.
WebSocket Connector Historical Versions:
|Python Connector Version|Main Changes|
|:-------------------:|:----:|
|2.7.16|Added subscription configuration (session.timeout.ms, max.poll.interval.ms)|
|2.7.15|Added support for VARBINARY and GEOMETRY types|
|2.7.14|Fixed known issues|
|2.7.13|Added tmq synchronous commit offset interface|
|2.7.12|1. Added support for varbinary type (STMT does not support varbinary yet) <br/> 2. Improved query performance (thanks to contributor [hadrianl](https://github.com/taosdata/taos-connector-python/pull/209))|
|2.7.9|Data subscription supports obtaining consumption progress and resetting consumption progress|
|2.7.8|Added `execute_many`|
|Python WebSocket Connector Version|Major Changes|
|:----------------------------:|:-----:|
|0.3.5|Added support for VARBINARY and GEOMETRY types, fixed known issues|
|0.3.2|Optimized WebSocket SQL query and insertion performance, updated readme and documentation, fixed known issues|
|0.2.9|Fixed known issues|
|0.2.5|1. Data subscription supports obtaining and resetting consumption progress <br/> 2. Supports schemaless <br/> 3. Supports STMT|
|0.2.4|Data subscription adds unsubscribe method|
|WebSocket Connector Version | Major Changes | TDengine Version|
| ----------------------- | -------------------------------------------------------------------------------------------------- | ----------------- |
|0.3.5 | Added support for VARBINARY and GEOMETRY types, fixed known issues. | 3.3.0.0 and higher|
|0.3.2 | Optimize WebSocket SQL query and insertion performance, modify readme and documentation, fix known issues. | 3.2.3.0 and higher|
|0.2.9 | Known issue fixes. | - |
|0.2.5 | 1. Data subscription supports obtaining and resetting consumption progress. <br/>2 Support schemaless. <br/>3 Support STMT. | - |
|0.2.4 | Data Subscription Addition/Unsubscribe Method. | 3.0.5.0 and higher|
## Exception Handling
@ -69,7 +85,7 @@ The Python connector may generate 4 types of exceptions:
- For other TDengine module errors, please refer to [Error Codes](../../error-codes/)
|Error Type|Description|Suggested Actions|
|:--------:|:---------:|:---------------:|
|:---------|:----------|:----------------|
|InterfaceError|taosc version too low, does not support the used interface|Please check the TDengine client version|
|ConnectionError|Database connection error|Please check the TDengine server status and connection parameters|
|DatabaseError|Database error|Please check the TDengine server version and upgrade the Python connector to the latest version|
@ -94,7 +110,7 @@ All database operations in the Python Connector, if an exception occurs, will be
TDengine currently supports timestamp, numeric, character, boolean types, and the corresponding Python type conversions are as follows:
|TDengine DataType|Python DataType|
|:---------------:|:-------------:|
|:---------------|:--------------|
|TIMESTAMP|datetime|
|INT|int|
|BIGINT|int|
@ -129,7 +145,7 @@ Example program source code can be found at:
## About Nanosecond (nanosecond)
Due to the current imperfect support for nanoseconds in Python (see the links below), the current implementation returns an integer when nanosecond precision is used, rather than the datetime type returned for ms and us. Application developers need to handle this themselves, and it is recommended to use pandas' to_datetime(). If Python officially fully supports nanoseconds in the future, the Python connector may modify the relevant interfaces.
## Common Questions
Feel free to [ask questions or report issues](https://github.com/taosdata/taos-connector-python/issues).

View File

@ -6,29 +6,27 @@ slug: /tdengine-reference/client-libraries/node
import Tabs from "@theme/Tabs";
import TabItem from "@theme/TabItem";
import RequestId from "./_request_id.mdx";
import RequestId from "../../assets/resources/_request_id.mdx";
`@tdengine/websocket` is the official Node.js language connector for TDengine. Node.js developers can use it to develop applications that access the TDengine database.
The source code for the Node.js connector is hosted on [GitHub](https://github.com/taosdata/taos-connector-node/tree/main).
## Connection Method
## Node.js Version Compatibility
The Node.js connector currently only supports WebSocket connections, which connect to a TDengine instance through the WebSocket interface provided by taosAdapter.
For a detailed introduction to the connection method, please refer to: [Connection Method](../../../developer-guide/connecting-to-tdengine/)
Supports Node.js 14 and above.
## Supported Platforms
Supports Node.js version 14 and above.
Support all platforms that can run Node.js.
## Version History
| Node.js Connector Version | Major Changes | TDengine Version |
| :------------------: | :----------------------: | :----------------: |
| 3.1.2 | Optimized data protocol and parsing, significantly improved performance| 3.3.2.0 and higher versions |
| 3.1.1 | Optimized data transmission performance | 3.3.2.0 and higher versions |
| 3.1.0 | New release, supports WebSocket connection | 3.2.0.0 and higher versions |
| Node.js Connector Version | Major Changes | TDengine Version |
| ------------------------- | ------------------------------------------------------------------------ | --------------------------- |
| 3.1.2 | Optimized data protocol and parsing, significantly improved performance. | - |
| 3.1.1 | Optimized data transmission performance. | 3.3.2.0 and higher versions |
| 3.1.0 | New release, supports WebSocket connection. | 3.2.0.0 and higher versions |
## Exception Handling
@ -38,19 +36,19 @@ Error description: Node.js connector error codes range from 100 to 110, errors o
For specific connector error codes, please refer to:
| Error Code | Description | Suggested Actions |
| ---------- | -------------------------------------------------------------| ----------------------------------------------------------------------------------------- |
| 100 | invalid variables | The parameters are illegal, please check the corresponding interface specifications and adjust the parameter types and sizes. |
| 101 | invalid url | URL error, please check if the URL is correctly filled. |
| 102 | received server data but did not find a callback for processing | Received server data but no upper layer callback was found |
| 103 | invalid message type | Received message type unrecognized, please check if the server is normal. |
| 104 | connection creation failed | Connection creation failed, please check if the network is normal. |
| 105 | websocket request timeout | Request timed out |
| 106 | authentication fail | Authentication failed, please check if the username and password are correct. |
| 107 | unknown sql type in tdengine | Please check the Data Type types supported by TDengine. |
| 108 | connection has been closed | The connection has been closed, please check if the Connection is used again after closing, or if the connection is normal. |
| 109 | fetch block data parse fail | Failed to parse the fetched query data |
| 110 | websocket connection has reached its maximum limit | WebSocket connection has reached its maximum limit |
| Error Code | Description | Suggested Actions |
| ---------- | --------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
| 100 | invalid variables | The parameters are illegal, please check the corresponding interface specifications and adjust the parameter types and sizes. |
| 101 | invalid url | URL error, please check if the URL is correctly filled. |
| 102 | received server data but did not find a callback for processing | Received server data but no upper layer callback was found |
| 103 | invalid message type | Received message type unrecognized, please check if the server is normal. |
| 104 | connection creation failed | Connection creation failed, please check if the network is normal. |
| 105 | websocket request timeout | Request timed out |
| 106 | authentication fail | Authentication failed, please check if the username and password are correct. |
| 107 | unknown sql type in tdengine | Please check the Data Type types supported by TDengine. |
| 108 | connection has been closed | The connection has been closed, please check if the Connection is used again after closing, or if the connection is normal. |
| 109 | fetch block data parse fail | Failed to parse the fetched query data |
| 110 | websocket connection has reached its maximum limit | WebSocket connection has reached its maximum limit |
- [TDengine Node.js Connector Error Code](https://github.com/taosdata/taos-connector-node/blob/main/nodejs/src/common/wsError.ts)
- For errors from other TDengine modules, please refer to [Error Codes](../../error-codes/)
@ -59,38 +57,38 @@ For specific connector error codes, please refer to:
The table below shows the mapping between TDengine DataType and Node.js DataType
| TDengine DataType | Node.js DataType|
|-------------------|-------------|
| TIMESTAMP | bigint |
| TINYINT | number |
| SMALLINT | number |
| INT | number |
| BIGINT | bigint |
| TINYINT UNSIGNED | number |
| SMALLINT UNSIGNED | number |
| INT UNSIGNED | number |
| BIGINT UNSIGNED | bigint |
| FLOAT | number |
| DOUBLE | number |
| BOOL | boolean |
| BINARY | string |
| NCHAR | string |
| JSON | string |
| VARBINARY | ArrayBuffer |
| GEOMETRY | ArrayBuffer |
| TDengine DataType | Node.js DataType |
| ----------------- | ---------------- |
| TIMESTAMP | bigint |
| TINYINT | number |
| SMALLINT | number |
| INT | number |
| BIGINT | bigint |
| TINYINT UNSIGNED | number |
| SMALLINT UNSIGNED | number |
| INT UNSIGNED | number |
| BIGINT UNSIGNED | bigint |
| FLOAT | number |
| DOUBLE | number |
| BOOL | boolean |
| BINARY | string |
| NCHAR | string |
| JSON | string |
| VARBINARY | ArrayBuffer |
| GEOMETRY | ArrayBuffer |
**Note**: JSON type is only supported in tags.
## More Example Programs
| Example Program | Description of Example Program |
| ------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------- |
| [sql_example](https://github.com/taosdata/TDengine/tree/main/docs/examples/node/websocketexample/sql_example.js) | Basic usage such as establishing connections, executing SQL, etc. |
| [stmt_example](https://github.com/taosdata/TDengine/tree/main/docs/examples/node/websocketexample/stmt_example.js) | Example of binding parameters for insertion. |
| [line_example](https://github.com/taosdata/TDengine/tree/main/docs/examples/node/websocketexample/line_example.js) | Line protocol writing example. |
| [tmq_example](https://github.com/taosdata/TDengine/tree/main/docs/examples/node/websocketexample/tmq_example.js) | Example of using subscriptions. |
| [all_type_query](https://github.com/taosdata/TDengine/tree/main/docs/examples/node/websocketexample/all_type_query.js) | Example supporting all types. |
| [all_type_stmt](https://github.com/taosdata/TDengine/tree/main/docs/examples/node/websocketexample/all_type_stmt.js) | Example of parameter binding supporting all types. |
| Example Program | Description of Example Program |
| ---------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------- |
| [sql_example](https://github.com/taosdata/TDengine/tree/main/docs/examples/node/websocketexample/sql_example.js) | Basic usage such as establishing connections, executing SQL, etc. |
| [stmt_example](https://github.com/taosdata/TDengine/tree/main/docs/examples/node/websocketexample/stmt_example.js) | Example of binding parameters for insertion. |
| [line_example](https://github.com/taosdata/TDengine/tree/main/docs/examples/node/websocketexample/line_example.js) | Line protocol writing example. |
| [tmq_example](https://github.com/taosdata/TDengine/tree/main/docs/examples/node/websocketexample/tmq_example.js) | Example of using subscriptions. |
| [all_type_query](https://github.com/taosdata/TDengine/tree/main/docs/examples/node/websocketexample/all_type_query.js) | Example supporting all types. |
| [all_type_stmt](https://github.com/taosdata/TDengine/tree/main/docs/examples/node/websocketexample/all_type_stmt.js) | Example of parameter binding supporting all types. |
## Usage Restrictions

View File

@ -6,42 +6,31 @@ slug: /tdengine-reference/client-libraries/csharp
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import RequestId from "./_request_id.mdx";
import RequestId from "../../assets/resources/_request_id.mdx";
`TDengine.Connector` is the C# language connector provided by TDengine. C# developers can use it to develop C# applications that access data in the TDengine cluster.
## Connection Methods
## .Net Version Compatibility
`TDengine.Connector` provides two types of connectors:
* **Native Connection**, which connects to a TDengine instance natively through the TDengine client driver (taosc), supporting data writing, querying, data subscription, schemaless interfaces, and parameter binding interfaces.
* **WebSocket Connection**, which connects to a TDengine instance through the WebSocket interface provided by taosAdapter, with a slightly different set of features implemented compared to the native connection. (From v3.0.1 onwards)
For a detailed introduction to connection methods, please refer to: [Connection Methods](../../../developer-guide/connecting-to-tdengine/)
## Compatibility
* `TDengine.Connector` version 3.1.0 has been completely restructured and is no longer compatible with versions 3.0.2 and earlier. For documentation on version 3.0.2, please refer to [nuget](https://www.nuget.org/packages/TDengine.Connector/3.0.2)
* `TDengine.Connector` 3.x is not compatible with TDengine 2.x. If you need to use the C# connector in an environment running TDengine 2.x, please use version 1.x of TDengine.Connector.
- Supports .NET Framework 4.6 and above.
- Supports .NET 5.0 and above.
## Supported Platforms
The supported platforms are consistent with those supported by the TDengine client driver.
- Native connection supports the same platforms as the TDengine client driver.
- WebSocket connection supports all platforms that can run the .NET runtime.
:::warning
TDengine no longer supports the 32-bit Windows platform.
:::
## Version History
## Version Support
| Connector Version | Major Changes | TDengine Version |
|------------------|-------------------------------------------------|-------------------|
| 3.1.4 | Improved WebSocket query and insert performance. | 3.3.2.0 and higher |
| 3.1.3 | Supported WebSocket auto-reconnect. | - |
| 3.1.2 | Fixed schemaless resource release. | - |
| 3.1.1 | Supported varbinary and geometry types. | - |
| 3.1.0 | WebSocket uses a native C# implementation. | 3.2.1.0 and higher |
| **Connector Version** | **TDengine Version** | **Main Features** |
|------------------|------------------|----------------------------|
| 3.1.3 | 3.2.1.0/3.1.1.18 | Supports WebSocket auto-reconnect |
| 3.1.2 | 3.2.1.0/3.1.1.18 | Fixes schemaless resource release |
| 3.1.1 | 3.2.1.0/3.1.1.18 | Supports varbinary and geometry types |
| 3.1.0 | 3.2.1.0/3.1.1.18 | Native implementation of WebSocket |
## Exception Handling
## Exceptions and Error Codes
`TDengine.Connector` will throw exceptions, and applications need to handle these exceptions. The taosc exception type `TDengineError` includes an error code and error message, which applications can use to handle the error.
For error reporting in other TDengine modules, please refer to [Error Codes](../../error-codes/)

View File

@ -6,7 +6,7 @@ slug: /tdengine-reference/client-libraries/r-lang
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import Rdemo from "../../07-develop/_connect_r.mdx"
import Rdemo from "../../assets/resources/_connect_r.mdx"
The RJDBC library in R language can enable R language programs to access TDengine data. Here are the installation process, configuration process, and R language example code.

View File

@ -20,7 +20,7 @@ TDengine ODBC provides both 64-bit and 32-bit drivers. However, the 32-bit versi
## ODBC Version Compatibility
- Supports ODBC 3.8 and all previous versions.
Supports all ODBC versions.
## Installation
@ -119,12 +119,12 @@ In addition to this, the WebSocket connection method also supports 32-bit applic
## Version History
| taos_odbc Version | Main Changes | TDengine Version |
| :----------- | :-------------------------------------------------------------------------------------------------- | :---------------- |
| v1.1.0 | 1. Supports view functionality;<br/>2. Supports VARBINARY/GEOMETRY data types;<br/>3. Supports ODBC 32-bit WebSocket connection method (Enterprise edition only);<br/>4. Supports ODBC data source configuration dialog settings for compatibility adaptation options for industrial software like KingSCADA, Kepware, etc. (Enterprise edition only); | 3.3.3.0 and higher |
| v1.0.2 | Supports CP1252 character encoding; | 3.2.3.0 and higher |
| v1.0.1 | 1. Supports DSN settings for BI mode, in BI mode TDengine database does not return system database and supertable subtable information;<br/>2. Refactored character set conversion module, improving read and write performance;<br/>3. Default connection method in ODBC data source configuration dialog changed to "WebSocket";<br/>4. Added "Test Connection" control in ODBC data source configuration dialog;<br/>5. ODBC data source configuration supports Chinese/English interface; | - |
| v1.0.0.0 | Initial release, supports interacting with Tdengine database to read and write data, refer to the "API Reference" section for details | 3.2.2.0 and higher |
| taos_odbc Version | Major Changes | TDengine Version |
| ----------- | -------------------------------------------------------------------------------------------------- | ---------------- |
| v1.1.0 | 1. Supports view functionality. <br/>2. Supports VARBINARY/GEOMETRY data types. <br/>3. Supports ODBC 32-bit WebSocket connection method (Enterprise edition only). <br/>4. Supports ODBC data source configuration dialog settings for compatibility adaptation options for industrial software like KingSCADA, Kepware, etc. (Enterprise edition only). | 3.3.3.0 and higher |
| v1.0.2 | Supports CP1252 character encoding. | 3.2.3.0 and higher |
| v1.0.1 | 1. Supports DSN settings for BI mode, in BI mode TDengine database does not return system database and supertable subtable information. <br/>2. Refactored character set conversion module, improving read and write performance. <br/> 3. Default connection method in ODBC data source configuration dialog changed to "WebSocket". <br/>4. Added "Test Connection" control in ODBC data source configuration dialog. <br/>5. ODBC data source configuration supports Chinese/English interface. | - |
| v1.0.0.0 | Initial release, supports interacting with Tdengine database to read and write data, refer to the "API Reference" section for details. | 3.2.2.0 and higher |
## Data Type Mapping

View File

@ -7,12 +7,12 @@ import Tabs from "@theme/Tabs";
import TabItem from "@theme/TabItem";
import Image from '@theme/IdealImage';
import imgClientLib from '../../assets/client-libraries-01.png';
import InstallOnLinux from "./_linux_install.mdx";
import InstallOnWindows from "./_windows_install.mdx";
import InstallOnMacOS from "./_macos_install.mdx";
import VerifyWindows from "./_verify_windows.mdx";
import VerifyLinux from "./_verify_linux.mdx";
import VerifyMacOS from "./_verify_macos.mdx";
import InstallOnLinux from "../../assets/resources/_linux_install.mdx";
import InstallOnWindows from "../../assets/resources/_windows_install.mdx";
import InstallOnMacOS from "../../assets/resources/_macos_install.mdx";
import VerifyWindows from "../../assets/resources/_verify_windows.mdx";
import VerifyLinux from "../../assets/resources/_verify_linux.mdx";
import VerifyMacOS from "../../assets/resources/_verify_macos.mdx";
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.

View File

@ -79,7 +79,7 @@ class _MyForecastService(AbstractForecastService):
```
将该文件保存在 `./taosanalytics/algo/fc/` 目录下,然后重启 taosanode 服务。在 TDengine 命令行接口中执行 `SHOW ANODES FULL` 能够看到新加入的算法。应用就可以通过 SQL 语句调用该预测算法。
将该文件保存在 `./lib/taosanalytics/algo/fc/` 目录下,然后重启 taosanode 服务。在 TDengine 命令行接口中执行 `SHOW ANODES FULL` 能够看到新加入的算法。应用就可以通过 SQL 语句调用该预测算法。
```SQL
--- 对 col 列进行异常检测,通过指定 algo 参数为 myfc 来调用新添加的预测类

View File

@ -15,7 +15,6 @@ sidebar_label: "异常检测"
下面我们开发一个示例异常检测算法,在异常检测中,将输入时间序列值的最后一个值设置为异常值,并返回结果。
```python
import numpy as np
from taosanalytics.service import AbstractAnomalyDetectionService
# 算法实现类名称 需要以下划线 "_" 开始,并以 Service 结束
@ -33,7 +32,7 @@ class _MyAnomalyDetectionService(AbstractAnomalyDetectionService):
super().__init__()
def execute(self):
""" 算法逻辑的核心实现"""
""" 算法逻辑的核心实现"""
"""创建一个长度为 len(self.list),全部值为 1 的结果数组,然后将最后一个值设置为 -1表示最后一个值是异常值"""
res = [1] * len(self.list)
@ -44,11 +43,11 @@ class _MyAnomalyDetectionService(AbstractAnomalyDetectionService):
def set_params(self, params):
"""该算法无需任何输入参数,直接重载父类该函数,不处理算法参数设置逻辑"""
"""该算法无需任何输入参数,直接重载父类该函数,不处理算法参数设置逻辑"""
pass
```
将该文件保存在 `./taosanalytics/algo/ad/` 目录下,然后重启 taosanode 服务。在 TDengine 命令行接口 taos 中执行 `SHOW ANODES FULL` 就能够看到新加入的算法,然后应用就可以通过 SQL 语句调用该检测算法。
将该文件保存在 `./lib/taosanalytics/algo/ad/` 目录下,然后重启 taosanode 服务。在 TDengine 命令行接口 taos 中执行 `SHOW ANODES FULL` 就能够看到新加入的算法,然后应用就可以通过 SQL 语句调用该检测算法。
```SQL
--- 对 col 列进行异常检测,通过指定 algo 参数为 myad 来调用新添加的异常检测类

View File

@ -22,24 +22,24 @@ toc_max_heading_level: 4
配置JDBC数据源的步骤如下。
第1步在打开的永洪BI中点击“添加数据源”按钮选择SQL数据源中的“GENERIC”类型。
第2步点击“选择自定义驱动”按钮在“驱动管理”对话框中点击“驱动列表”旁边的“+”输入名称“MyTDengine”。然后点击“上传文件”按钮上传刚刚下载的TDengine JDBC连接器文件“taos-jdbcdriver-3.2.7-dist.jar”并选择“com.taosdata.jdbc.
rs.RestfulDriver”驱动最后点击“确定”按钮完成驱动添加步骤。
第3步复制下面的内容到“URL”字段。
第1步在打开的永洪BI中点击“添加数据源”按钮选择SQL数据源中的“GENERIC”类型。
第2步点击“选择自定义驱动”按钮在“驱动管理”对话框中点击“驱动列表”旁边的“+”输入名称“MyTDengine”。然后点击“上传文件”按钮上传刚刚下载的TDengine JDBC连接器文件“taos-jdbcdriver-3.2.7-dist.jar”并选择“com.taosdata.jdbc.
rs.RestfulDriver”驱动最后点击“确定”按钮完成驱动添加步骤。
第3步复制下面的内容到“URL”字段。
```text
jdbc:TAOS-RS://127.0.0.1:6041?user=root&password=taosdata
```
第4步在“认证方式”中点击“无身份认证”单选按钮。
第5步在数据源的高级设置中修改“Quote 符号”的值为反引号(`)。
第6步点击“测试连接”按钮弹出“测试成功”对话框。点击“保存”按钮输入“MyTDengine”来保存TDengine数据源。
第4步在“认证方式”中点击“无身份认证”单选按钮。
第5步在数据源的高级设置中修改“Quote 符号”的值为反引号(`)。
第6步点击“测试连接”按钮弹出“测试成功”对话框。点击“保存”按钮输入“MyTDengine”来保存TDengine数据源。
## 创建TDengine数据集
创建TDengine数据集的步骤如下。
第1步在永洪BI中点击“添加数据源”按钮展开刚刚创建的数据源并浏览TDengine中的超级表。
第2步可以将超级表的数据全部加载到永洪BI中也可以通过自定义SQL导入部分数据。
第3步当勾选“数据库内计算”复选框时永洪BI将不再缓存TDengine的时序数据并在处理查询时将SQL请求发送给TDengine直接处理。
第1步在永洪BI中点击“添加数据源”按钮展开刚刚创建的数据源并浏览TDengine中的超级表。
第2步可以将超级表的数据全部加载到永洪BI中也可以通过自定义SQL导入部分数据。
第3步当勾选“数据库内计算”复选框时永洪BI将不再缓存TDengine的时序数据并在处理查询时将SQL请求发送给TDengine直接处理。
当导入数据后永洪BI会自动将数值类型设置为“度量”列将文本类型设置为“维度”列。而在TDengine的超级表中由于将普通列作为数据的度量将标签列作为数据的维度因此用户可能需要在创建数据集时更改部分列的属性。TDengine在支持标准SQL的基础之上还提供了一系列满足时序业务场景需求的特色查询语法例如数据切分查询、窗口切分查询等具体操作步骤请参阅TDengine的官方文档。通过使用这些特色查询当永洪BI将SQL查询发送到TDengine时可以大大提高数据访问速度减少网络传输带宽。

View File

@ -0,0 +1,73 @@
---
sidebar_label: Superset
title: 与 Superset 集成
---
Apache Superset 是一个现代的企业级商业智能BIWeb 应用程序,主要用于数据探索和可视化。它由 Apache 软件基金会支持是一个开源项目它拥有活跃的社区和丰富的生态系统。Apache Superset 提供了直观的用户界面,使得创建、分享和可视化数据变得简单,同时支持多种数据源和丰富的可视化选项‌。
通过 TDengine 的 Python 连接器, Superset 可支持 TDengine 数据源并提供数据展现、分析等功能
## 安装 Apache Superset
确保已安装 Apache Superset v2.1.0 及以上版本, 如未安装,请到其 [官网](https://superset.apache.org/) 安装
## 安装 TDengine
TDengine 企业版及社区版均可支持,版本要求在 3.0 及以上
## 安装 TDengine Python 连接器
TDengine Python 连接器从 `v2.1.18` 开始自带 Superset 连接驱动,安装程序会把连接驱动安装到 Superset 相应目录下并向 Superset 提供数据源服务
Superset 与 TDengine 之间使用 WebSocket 协议连接,所以需另安装支持 WebSocket 连接协议的组件 `taos-ws-py` , 全部安装脚本如下:
```bash
pip3 install taospy
pip3 install taos-ws-py
```
## Superset 中配置 TDengine 连接
**第 1 步**,进入新建数据库连接页面 "Superset" → "Setting" → "Database Connections" → "+DATABASE"
**第 2 步**,选择 TDengine 数据库连接。"SUPPORTED DATABASES" 下拉列表中选择 "TDengine" 项。
:::tip
注意:若下拉列表中无 "TDengine" 项,请检查安装顺序,确保 `TDengine Python 连接器``Superset` 安装之后再安装。
:::
**第 3 步**"DISPLAY NAME" 中填写连接名称,任意填写即可。
**第 4 步**"SQLALCHEMY URL" 项为关键连接信息串,务必填写正确。
```bash
taosws://用户名:密码@主机名:端口号
```
| 参数名称 | <center>参数说明</center> |
|:------- |:-------------------------------- |
| 用户名 | 登录 TDengine 数据库用户名 |
| 密码 | 登录 TDengine 数据库密码 |
| 主机名 | TDengine 数据库所在主机名称 |
| 端口号 | 提供 WebSocket 服务的端口默认6041 |
示例:
本机安装 TDengine 数据库WebSocket 服务端口 6041使用默认用户名密码"SQLALCHEMY URL" 应为:
```bash
taosws://root:taosdata@localhost:6041
```
第5步配置好连接串点击 “TEST CONNECTION” 测试连接是否成功,测试通过后点击 “CONNECT” 按钮,完成连接。
## 开始使用
TDengine 数据源与其它数据源使用上无差别,这里简单介绍下数据查询:
1. Superset 界面点击右上角 “+” 号按钮,选择 “SQL query”, 进入查询界面
2. 左上角 “DATABASE” 下拉列表中选择前面已创建好的 “TDengine” 数据源
3. “SCHEMA” 下拉列表,选择要操作的数据库名(系统库不显示)
4. “SEE TABLE SCHEMA” 选择要操作的超级表名或普通表名(子表不显示)
5. 随后会在下方显示选定表的 SCHEMA 信息
6. 在 SQL 编辑器区域可输入符合 TDengine 语法的任意 SQL 语句执行
## 示例效果
我们选择 Superset Chart 模板中较流行的两个模板做了效果展示,以智能电表数据为例:
1. "Aggregate" 类型,展示在第 4 组中指定时间段内每分钟采集电压值(voltage)最大值
![superset-demo1](./superset-demo1.jpeg)
2. "RAW RECORDS" 类型,展示在第 4 组中指定时间段内 current, voltage 的采集值
![superset-demo2](./superset-demo2.jpeg)

Binary file not shown.

After

Width:  |  Height:  |  Size: 650 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 784 KiB

View File

@ -59,7 +59,7 @@ taosd 命令行参数如下
|telemetryReporting | |支持动态修改 立即生效 |是否上传 telemetry0不上传1上传默认值 1|
|telemetryServer | |不支持动态修改 |telemetry 服务器地址|
|telemetryPort | |不支持动态修改 |telemetry 服务器端口编号|
|telemetryInterval | |支持动态修改 立即生效 |telemetry 上传时间间隔,单位为秒,默认 43200|
|telemetryInterval | |支持动态修改 立即生效 |telemetry 上传时间间隔,单位为秒,默认 86400|
|crashReporting | |支持动态修改 立即生效 |是否上传 crash 信息0不上传1上传默认值 1|
### 查询相关

View File

@ -37,8 +37,8 @@ TDengine 客户端驱动的动态库位于:
### 版本历史
| TDengine 客户端版本 | 主要变化 | TDengine 版本 |
| :------------------: | :---------------------------: | :----------------: |
| 3.3.3.0 | 首次发布,提供了 SQL执行参数绑定无模式写入和数据订阅等全面功能支持。 | 3.3.2.0及更高版本 |
| ------------------ | --------------------------- | ---------------- |
| 3.3.3.0 | 首次发布,提供了 SQL执行参数绑定无模式写入和数据订阅等全面功能支持。 | 3.3.2.0 及更高版本 |
### 错误码

View File

@ -19,45 +19,45 @@ TDengine 的 JDBC 驱动实现尽可能与关系型数据库驱动保持一致
:::
## JDBC 和 JRE 兼容性
## JDBC 和 JRE 版本兼容性
- JDBC: 支持 JDBC 4.2 版本,部分功能如无模式写入和数据订阅单独提供
- JRE: 支持 JRE 8 及以上版本
- JDBC: 支持 JDBC 4.2 及以上版本。
- JRE: 支持 JRE 8 及以上版本
## 支持的平台
原生连接支持的平台和 TDengine 客户端驱动支持的平台一致。
REST 连接支持所有能运行 Java 的平台。
- 原生连接支持的平台和 TDengine 客户端驱动支持的平台一致。
- WebSocket/REST 连接支持所有能运行 Java 的平台。
## 版本历史
| taos-jdbcdriver 版本 | 主要变化 | TDengine 版本 |
| :------------------: | :----------------------------------------------------------------------------------------------------------------------------------------------------: | :----------------: |
| 3.4.0 | 1. 使用 jackson 库替换 fastjson 库2. WebSocket 采用独立协议标识;3. 优化后台拉取线程使用,避免用户误用导致超时 | - |
| 3.3.4 | 1. 解决了 getInt 在数据类型为 float 报错 | - |
| 3.3.3 | 1. 解决了 WebSocket statement 关闭导致的内存泄漏 | - |
| 3.3.2 | 1. 优化 WebSocket 连接下的参数绑定性能2. 优化了对 mybatis 的支持 | - |
| 3.3.0 | 1. 优化 WebSocket 连接下的数据传输性能2. 支持跳过 SSL 验证,默认关闭 | 3.3.2.0 及更高版本 |
| ------------------| ---------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------- |
| 3.4.0 | 1. 使用 jackson 库替换 fastjson 库 <br/> 2. WebSocket 采用独立协议标识 <br/> 3. 优化后台拉取线程使用,避免用户误用导致超时 | - |
| 3.3.4 | 解决了 getInt 在数据类型为 float 报错 | - |
| 3.3.3 | 解决了 WebSocket statement 关闭导致的内存泄漏 | - |
| 3.3.2 | 1. 优化 WebSocket 连接下的参数绑定性能 <br/> 2. 优化了对 mybatis 的支持 | - |
| 3.3.0 | 1. 优化 WebSocket 连接下的数据传输性能 <br/> 2. 支持跳过 SSL 验证,默认关闭 | 3.3.2.0 及更高版本 |
| 3.2.11 | 解决了 Native 连接关闭结果集 bug | - |
| 3.2.10 | 1. REST/WebSocket 连接支持传输中的数据压缩2. WebSocket 自动重连机制默认关闭3. Connection 类提供无模式写入的方法4. 优化了原生连接的数据拉取性能5. 修复了一些已知问题;6.元数据获取函数可以返回支持的函数列表 | - |
| 3.2.10 | 1. REST/WebSocket 连接支持传输中的数据压缩 <br/> 2. WebSocket 自动重连机制,默认关闭 <br/> 3. Connection 类提供无模式写入的方法 <br/> 4. 优化了原生连接的数据拉取性能 <br/> 5. 修复了一些已知问题 <br/> 6.元数据获取函数可以返回支持的函数列表 | - |
| 3.2.9 | 解决了 WebSocket prepareStatement 关闭 bug | - |
| 3.2.8 | 优化了自动提交, 解决了 WebSocket 手动提交 bug, 优化 WebSocket prepareStatement 使用一个连接, 元数据支持视图 | - |
| 3.2.7 | 支持 VARBINARY 和 GEOMETRY 类型,增加 native 连接的时区设置支持。增加 WebSocket 自动重连功能。 | 3.2.0.0 及更高版本 |
| 3.2.5 | 数据订阅增加 committed()、assignment() 方法 | 3.1.0.3 及更高版本 |
| 3.2.4 | 数据订阅在 WebSocket 连接下增加 enable.auto.commit 参数,以及 unsubscribe() 方法 | - |
| 3.2.3 | 修复 ResultSet 在一些情况数据解析失败 | - |
| 3.2.2 | 新增功能:数据订阅支持 seek 功能 | 3.0.5.0 及更高版本 |
| 3.2.1 | 新增功能WebSocket 连接支持 schemaless 与 prepareStatement 写入。变更:consumer poll 返回结果集为 ConsumerRecord可通过 value() 获取指定结果集数据 | 3.0.3.0 及更高版本 |
| 3.2.0 | 存在连接问题,不推荐使用 | - |
| 3.1.0 | WebSocket 连接支持订阅功能 | - |
| 3.0.1 - 3.0.4 | 修复一些情况下结果集数据解析错误的问题。3.0.1 在 JDK 11 环境编译JDK 8 环境下建议使用其他版本 | - |
| 3.0.0 | 支持 TDengine 3.0 | 3.0.0.0 及更高版本 |
| 2.0.42 | 修复 WebSocket 连接中 wasNull 接口返回值 | - |
| 2.0.41 | 修复 REST 连接中用户名和密码转码方式 | - |
| 2.0.39 - 2.0.40 | 增加 REST 连接/请求 超时设置 | - |
| 2.0.38 | JDBC REST 连接增加批量拉取功能 | - |
| 2.0.37 | 增加对 json tag 支持 | - |
| 2.0.36 | 增加对 schemaless 写入支持 | - |
| 3.2.8 | 1. 优化了自动提交 <br/> 2. 解决了 WebSocket 手动提交 bug <br/> 3.优化 WebSocket prepareStatement 使用一个连接 <br/> 4.元数据支持视图 | - |
| 3.2.7 | 1. 支持 VARBINARY 和 GEOMETRY 类型 <br/> 2. 增加 native 连接的时区设置支持 <br/> 3. 增加 WebSocket 自动重连功能 | 3.2.0.0 及更高版本 |
| 3.2.5 | 数据订阅增加 committed()、assignment() 方法 | 3.1.0.3 及更高版本 |
| 3.2.4 | 数据订阅在 WebSocket 连接下增加 enable.auto.commit 参数,以及 unsubscribe 方法 | - |
| 3.2.3 | 修复 ResultSet 在一些情况数据解析失败 | - |
| 3.2.2 | 数据订阅支持 seek 功能 | 3.0.5.0 及更高版本 |
| 3.2.1 | 1. WebSocket 连接支持 schemaless 与 prepareStatement 写入 <br/> 2. consumer poll 返回结果集为 ConsumerRecord可通过 value() 获取指定结果集数据 | 3.0.3.0 及更高版本 |
| 3.2.0 | 存在连接问题,不推荐使用 | - |
| 3.1.0 | WebSocket 连接支持订阅功能 | - |
| 3.0.1 - 3.0.4 | 修复一些情况下结果集数据解析错误的问题。3.0.1 在 JDK 11 环境编译JDK 8 环境下建议使用其他版本 | - |
| 3.0.0 | 支持 TDengine 3.0 | 3.0.0.0 及更高版本 |
| 2.0.42 | 修复 WebSocket 连接中 wasNull 接口返回值 | - |
| 2.0.41 | 修复 REST 连接中用户名和密码转码方式 | - |
| 2.0.39 - 2.0.40 | 增加 REST 连接/请求 超时设置 | - |
| 2.0.38 | JDBC REST 连接增加批量拉取功能 | - |
| 2.0.37 | 增加对 json tag 支持 | - |
| 2.0.36 | 增加对 schemaless 写入支持 | - |
## 异常和错误码

View File

@ -12,20 +12,37 @@ import RequestId from "./_request_id.mdx";
`driver-go` 是 TDengine 的官方 Go 语言连接器,实现了 Go 语言 [database/sql](https://golang.org/pkg/database/sql/) 包的接口。Go 开发人员可以通过它开发存取 TDengine 集群数据的应用软件。
## 兼容性
## Go 版本兼容性
支持最低 Go 版本 1.14,建议使用最新 Go 版本
支持 Go 1.14 及以上版本。
## 支持的平台
原生连接支持的平台和 TDengine 客户端驱动支持的平台一致。
REST 连接支持所有能运行 Go 的平台。
- 原生连接支持的平台和 TDengine 客户端驱动支持的平台一致。
- WebSocket/REST 连接支持所有能运行 Go 的平台。
## 版本支持
## 版本历史
请参考[版本支持列表](https://github.com/taosdata/driver-go#remind)
| driver-go 版本 | 主要变化 | TDengine 版本 |
|-------------|-------------------------------------|---------------|
| v3.5.8 | 修复空指针异常 | - |
| v3.5.7 | taosWS 和 taosRestful 支持传入 request id | - |
| v3.5.6 | 提升 websocket 查询和写入性能 | 3.3.2.0 及更高版本 |
| v3.5.5 | restful 支持跳过 ssl 证书检查 | - |
| v3.5.4 | 兼容 TDengine 3.3.0.0 tmq raw data | - |
| v3.5.3 | 重构 taosWS | - |
| v3.5.2 | websocket 压缩和优化消息订阅性能 | 3.2.3.0 及更高版本 |
| v3.5.1 | 原生 stmt 查询和 geometry 类型支持 | 3.2.1.0 及更高版本 |
| v3.5.0 | 获取消费进度及按照指定进度开始消费 | 3.0.5.0 及更高版本 |
| v3.3.1 | 基于 websocket 的 schemaless 协议写入 | 3.0.4.1 及更高版本 |
| v3.1.0 | 提供贴近 kafka 的订阅 api | - |
| v3.0.4 | 新增 request id 相关接口 | 3.0.2.2 及更高版本 |
| v3.0.3 | 基于 websocket 的 statement 写入 | - |
| v3.0.2 | 基于 websocket 的数据查询和写入 | 3.0.1.5 及更高版本 |
| v3.0.1 | 基于 websocket 的消息订阅 | - |
| v3.0.0 | 适配 TDengine 3.0 查询和写入 | 3.0.0.0 及更高版本 |
## 处理异常
## 异常和错误码
如果是 TDengine 错误可以通过以下方式获取错误码和错误信息。

View File

@ -4,49 +4,44 @@ sidebar_label: Rust
title: TDengine Rust Connector
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import Tabs from "@theme/Tabs";
import TabItem from "@theme/TabItem";
import Preparation from "./_preparation.mdx"
import Preparation from "./_preparation.mdx";
import RequestId from "./_request_id.mdx";
<figure>
[![Crates.io](https://img.shields.io/crates/v/taos)](https://crates.io/crates/taos) ![Crates.io](https://img.shields.io/crates/d/taos) [![docs.rs](https://img.shields.io/docsrs/taos)](https://docs.rs/taos)
</figure>
`taos` 是 TDengine 的官方 Rust 语言连接器Rust 开发人员可以通过它开发存取 TDengine 数据库的应用软件。
`taos` 是 TDengine 的官方 Rust 语言连接器Rust 开发人员可以通过它开发存取 TDengine 数据库的应用软件。
该 Rust 连接器的源码托管在 [GitHub](https://github.com/taosdata/taos-connector-rust)。
## 连接方式
## Rust 版本兼容性
`taos` 提供两种建立连接的方式。一般我们推荐使用 **WebSocket 连接**。
- **原生连接**,它通过 TDengine 客户端驱动程序taosc连接 TDengine 运行实例。
- **WebSocket 连接**,它通过 taosAdapter 的 WebSocket 接口连接 TDengine 运行实例。
你可以通过不同的 “特性(即 Cargo 关键字 `features`)” 来指定使用哪种连接器(默认同时支持)。
连接方式的详细介绍请参考:[连接方式](../../../develop/connect/#连接方式)
支持 Rust 1.70 及以上版本。
## 支持的平台
原生连接支持的平台和 TDengine 客户端驱动支持的平台一致。
WebSocket 连接支持所有能运行 Rust 的平台。
- 原生连接支持的平台和 TDengine 客户端驱动支持的平台一致。
- WebSocket 连接支持所有能运行 Rust 的平台。
## 版本历史
| Rust 连接器版本 | TDengine 版本 | 主要功能 |
| :----------------: | :--------------: | :--------------------------------------------------: |
| v0.12.3 | 3.3.0.0 or later | 优化了 WebSocket 查询和插入性能,支持了 VARBINARY 和 GEOMETRY 类型 |
| v0.12.0 | 3.2.3.0 or later | WS 支持压缩。 |
| v0.11.0 | 3.2.0.0 | TMQ 功能优化。 |
| v0.10.0 | 3.1.0.0 | WS endpoint 变更。 |
| v0.9.2 | 3.0.7.0 | STMTws 下获取 tag_fields、col_fields。 |
| v0.8.12 | 3.0.5.0 | 消息订阅:获取消费进度及按照指定进度开始消费 |
| v0.8.0 | 3.0.4.0 | 支持无模式写入。 |
| v0.7.6 | 3.0.3.0 | 支持在请求中使用 req_id。 |
| v0.6.0 | 3.0.0.0 | 基础功能。 |
| Rust 连接器版本 | 主要变化 | TDengine 版本 |
| -------------- | ---------------------------------------------------------------------------- | ----------------- |
| v0.12.3 | 1. 优化了 WebSocket 查询和插入性能 <br/> 2. 支持了 VARBINARY 和 GEOMETRY 类型 | 3.3.0.0 及更高版本 |
| v0.12.0 | WebSocket 支持压缩 | 3.2.3.0 及更高版本 |
| v0.11.0 | TMQ 功能优化 | 3.2.0.0 及更高版本 |
| v0.10.0 | WebSocket endpoint 变更 | 3.1.0.0 及更高版本 |
| v0.9.2 | STMTWebSocket 下获取 tag_fields、col_fields | 3.0.7.0 及更高版本 |
| v0.8.12 | 消息订阅:获取消费进度及按照指定进度开始消费 | 3.0.5.0 及更高版本 |
| v0.8.0 | 支持无模式写入 | 3.0.4.0 及更高版本 |
| v0.7.6 | 支持在请求中使用 req_id | 3.0.3.0 及更高版本 |
| v0.6.0 | 基础功能 | 3.0.0.0 及更高版本 |
## 处理错误
## 异常和错误码
在报错后,可以获取到错误的具体信息:
@ -61,7 +56,8 @@ match conn.exec(sql) {
}
}
```
错误信息的错误码可以参考:[错误码](../../../reference/error-code)
错误信息的错误码可以参考:[错误码](../../../reference/error-code)
## 数据类型映射
@ -80,14 +76,14 @@ TDengine 目前支持时间戳、数字、字符、布尔类型,与 Rust 对
| BINARY | Vec\<u8> |
| NCHAR | String |
| JSON | serde_json::Value |
| VARBINARY | Bytes |
| GEOMETRY | Bytes |
| VARBINARY | Bytes |
| GEOMETRY | Bytes |
**注意**JSON 类型仅在 tag 中支持。
## 示例程序汇总
示例程序源码请参考:[rust example](https://github.com/taosdata/TDengine/tree/main/docs/examples/rust)
请参考:[rust example](https://github.com/taosdata/TDengine/tree/main/docs/examples/rust)
## 常见问题
@ -96,9 +92,10 @@ TDengine 目前支持时间戳、数字、字符、布尔类型,与 Rust 对
## API 参考
Rust 连接器的接口分为同步接口和异步接口,一般同步接口是由异步接口实现,方法签名除 async 关键字外基本相同。对于同步接口和异步接口功能一样的接口,本文档只提供同步接口的说明。
对于 WebSocket 连接和原生连接两种方式,除了建立连接的 DSN 不同,其余接口调用没有区别。
对于 WebSocket 连接和原生连接两种方式,除了建立连接的 DSN 不同,其余接口调用没有区别。
### 连接功能
### 连接功能
#### DSN
TaosBuilder 通过 DSN 连接描述字符串创建一个连接构造器。
@ -126,29 +123,35 @@ DSN 描述字符串基本结构如下:
一个完整的 DSN 描述字符串示例如下:`taos+ws://localhost:6041/test` 表示使用 WebSocket`ws`)方式通过 `6041` 端口连接服务器 `localhost`,并指定默认数据库为 `test`。
#### TaosBuilder
TaosBuilder 结构体主要提供了根据 DSN 构建 Taos 对象的方法,还提供了检查连接,以及获取客户端版本号等功能。
- `fn available_params() -> &'static [&'static str]`
- **接口说明**:获取 DSN 中可用的参数列表。
- **返回值**:返回静态字符串切片的引用,包含可用的参数名称。
- `fn from_dsn<D: IntoDsn>(dsn: D) -> RawResult<Self>`
- **接口说明**:使用 DSN 字符串创建连接,不检查连接。
- **参数说明**
- `dsn`DSN 字符串或可转换为 DSN 的类型。
- **返回值**:成功时返回自身类型的 `RawResult`,失败时返回错误。
- `fn client_version() -> &'static str`
- **接口说明**:获取客户端版本。
- **返回值**:返回客户端版本的静态字符串。
- `fn ping(&self, _: &mut Self::Target) -> RawResult<()>`
- **接口说明**:检查连接是否仍然存活。
- **参数说明**
- `_`:目标连接的可变引用。
- **返回值**:成功时返回空的 `RawResult`,失败时返回错误。
- `fn ready(&self) -> bool`
- **接口说明**:检查是否准备好连接。
- **返回值**:大多数情况下返回 `true`,表示地址准备好连接。
@ -157,26 +160,32 @@ TaosBuilder 结构体主要提供了根据 DSN 构建 Taos 对象的方法,还
- **返回值**:成功时返回目标连接类型的 `RawResult`,失败时返回错误。
### 执行 SQL
执行 SQL 主要使用 Taos 结构体,获取结果集以及元数据需要使用下节介绍的 ResultSet 结构体 和列信息 Field 结构体。
#### Taos
Taos 结构体提供了多个数据库操作的 API包括执行 SQL无模式写入以及一些常用数据库查询的封装如创建数据库获取
- `pub fn is_native(&self) -> bool`
- **接口说明**:判断连接是否使用本地协议。
- **返回值**:如果使用本地协议,则返回 `true`,否则返回 `false`。
- `pub fn is_ws(&self) -> bool`
- **接口说明**判断连接是否使用websocket协议。
- **返回值**如果使用websocket协议则返回 `true`,否则返回 `false`。
- **接口说明**:判断连接是否使用 WebSocket 协议。
- **返回值**:如果使用 WebSocket 协议,则返回 `true`,否则返回 `false`。
- `fn query<T: AsRef<str>>(&self, sql: T) -> RawResult<Self::ResultSet>`
- **接口说明**:执行 SQL 查询。
- **参数说明**
- `sql`:要执行的 SQL 语句。
- **返回值**:成功时返回结果集 `ResultSet` 的 `RawResult`,失败时返回错误。
- `fn query_with_req_id<T: AsRef<str>>(&self, sql: T, req_id: u64) -> RawResult<Self::ResultSet>`
- **接口说明**:带请求 ID 执行 SQL 查询。
- **参数说明**
- `sql`:要执行的 SQL 语句。
@ -184,49 +193,58 @@ Taos 结构体提供了多个数据库操作的 API包括执行 SQL
- **返回值**:成功时返回结果集 `ResultSet` 的 `RawResult`,失败时返回错误。
- `fn exec<T: AsRef<str>>(&self, sql: T) -> RawResult<usize>`
- **接口说明**:执行 SQL 语句。
- **参数说明**
- `sql`:要执行的 SQL 语句。
- **返回值**:成功时返回受影响的行数,失败时返回错误。
- `fn exec_many<T: AsRef<str>, I: IntoIterator<Item = T>>(&self, input: I) -> RawResult<usize>`
- **接口说明**:批量执行 SQL 语句。
- **参数说明**
- `input`:要执行的 SQL 语句集合。
- **返回值**:成功时返回总共受影响的行数,失败时返回错误。
- `fn query_one<T: AsRef<str>, O: DeserializeOwned>(&self, sql: T) -> RawResult<Option<O>>`
- **接口说明**:执行 SQL 查询并返回单个结果。
- **参数说明**
- `sql`:要执行的 SQL 语句。
- **返回值**:成功时返回可选的结果对象,失败时返回错误。
- `fn server_version(&self) -> RawResult<Cow<str>>`
- **接口说明**:获取服务器版本。
- **返回值**:成功时返回服务器版本字符串的 `RawResult`,失败时返回错误。
- `fn create_topic(&self, name: impl AsRef<str>, sql: impl AsRef<str>) -> RawResult<()>`
- **接口说明**:创建主题。
- **参数说明**
- `name`:主题名称。
- `sql`:关联的 SQ L语句。
- `sql`:关联的 SQL 语句。
- **返回值**:成功时返回空的 `RawResult`,失败时返回错误。
- `fn databases(&self) -> RawResult<Vec<ShowDatabase>>`
- **接口说明**:获取数据库列表。
- **返回值**:成功时返回数据库列表的 `RawResult`,失败时返回错误。
- `fn topics(&self) -> RawResult<Vec<Topic>>`
- **接口说明**:获取主题信息。
- **返回值**:成功时返回主题列表的 `RawResult`,失败时返回错误。
- `fn describe(&self, table: &str) -> RawResult<Describe>`
- **接口说明**:描述表结构。
- **参数说明**
- `table`:表名称。
- **返回值**:成功时返回表结构描述的 `RawResult`,失败时返回错误。
- `fn database_exists(&self, name: &str) -> RawResult<bool>`
- **接口说明**:检查数据库是否存在。
- **参数说明**
- `name`:数据库名称。
@ -238,9 +256,12 @@ Taos 结构体提供了多个数据库操作的 API包括执行 SQL
- `data`:无模式数据。
- **返回值**:成功时返回空的 `RawResult`,失败时返回错误。
### SmlData
### SmlData
SmlData 结构体提供了无模式写入的数据结构,以及获取属性的方法。
- `pub struct SmlData`
- **结构体说明**`SmlData` 结构体用于存储无模式数据及其相关信息。
- **字段说明**
- `protocol`:无模式协议,支持 InfluxDB `Line`, OpenTSDB `Telnet`, OpenTSDB `Json`, 三种。
@ -250,18 +271,22 @@ SmlData 结构体提供了无模式写入的数据结构,以及获取属性的
- `req_id`:请求 ID。
- `pub fn protocol(&self) -> SchemalessProtocol`
- **接口说明**:获取无模式协议。
- **返回值**:无模式协议类型,支持 InfluxDB `Line`, OpenTSDB `Telnet`, OpenTSDB `Json`, 三种。
- `pub fn precision(&self) -> SchemalessPrecision`
- **接口说明**:获取时间戳精度。
- **返回值**:时间戳精度类型,支持 `Hours`, `Minutes`, `Seconds`, `Millisecond`(默认), `Microsecond`, `Nanosecond`。
- `pub fn data(&self) -> &Vec<String>`
- **接口说明**:获取数据列表。
- **返回值**:数据列表的引用。
- `pub fn ttl(&self) -> Option<i32>`
- **接口说明**:获取数据存活时间。
- **返回值**:数据存活时间(可选),单位为秒。
@ -269,39 +294,49 @@ SmlData 结构体提供了无模式写入的数据结构,以及获取属性的
- **接口说明**:获取请求 ID。
- **返回值**:请求 ID可选
### 结果获取
### 结果获取
#### ResultSet
ResultSet 结构体提供了结果集的一些方法,可以用来获取结果集的数据和元数据。
- `fn affected_rows(&self) -> i32`
- **接口说明**:获取受影响的行数。
- **返回值**:受影响的行数,类型为 `i32`。
- `fn precision(&self) -> Precision`
- **接口说明**:获取精度信息。
- **返回值**:精度信息,类型为 `Precision`。
- `fn fields(&self) -> &[Field]`
- **接口说明**:获取字段信息。见下文 Feild 结构体描述。
- **返回值**:字段信息数组的引用。
- `fn summary(&self) -> (usize, usize)`
- **接口说明**:获取摘要信息。
- **返回值**:包含两个 `usize` 类型的元组,分别表示某些统计信息。
- `fn num_of_fields(&self) -> usize`
- **接口说明**:获取字段数量。
- **返回值**:字段数量,类型为 `usize`。
- `fn blocks(&mut self) -> IBlockIter<'_, Self>`
- **接口说明**:获取原始数据块的迭代器。
- **返回值**:原始数据块的迭代器,类型为 `IBlockIter<'_, Self>`。
- `fn rows(&mut self) -> IRowsIter<'_, Self>`
- **接口说明**:获取按行查询的迭代器。
- **返回值**:按行查询的迭代器,类型为 `IRowsIter<'_, Self>`。
- `fn deserialize<T>(&mut self) -> Map<IRowsIter<'_, Self>, fn(_: Result<RowView<'_>, Error>) -> Result<T, Error>>`
- **接口说明**:反序列化行数据。
- **泛型参数**
- `T`:目标类型,需实现 `DeserializeOwned`。
@ -311,14 +346,17 @@ ResultSet 结构体提供了结果集的一些方法,可以用来获取结果
- **接口说明**:将结果集转换为值的二维向量。
- **返回值**:成功时返回值的二维向量,失败时返回错误,类型为 `Result<Vec<Vec<Value>>, Error>`。
#### Feild
#### Feild
Feild 结构体提供了字段信息的一些方法。
- `pub const fn empty() -> Field`
- **接口说明**:创建一个空的 `Field` 实例。
- **返回值**:返回一个空的 `Field` 实例。
- `pub fn new(name: impl Into<String>, ty: Ty, bytes: u32) -> Field`
- **接口说明**:创建一个新的 `Field` 实例。
- **参数说明**
- `name`:字段名称。
@ -327,22 +365,27 @@ Feild 结构体提供了字段信息的一些方法。
- **返回值**:返回一个新的 `Field` 实例。
- `pub fn name(&self) -> &str`
- **接口说明**:获取字段名称。
- **返回值**:返回字段的名称。
- `pub fn escaped_name(&self) -> String`
- **接口说明**:获取转义后的字段名称。
- **返回值**:返回转义后的字段名称。
- `pub const fn ty(&self) -> Ty`
- **接口说明**:获取字段类型。
- **返回值**:返回字段的类型。
- `pub const fn bytes(&self) -> u32`
- **接口说明**:获取字段的预设长度。
- **返回值**:对于变长数据类型,返回其预设长度;对于其他类型,返回其字节宽度。
- `pub fn to_c_field(&self) -> c_field_t`
- **接口说明**:将 `Field` 实例转换为 C 语言结构体。
- **返回值**:返回 C 语言结构体表示的字段。
@ -351,17 +394,22 @@ Feild 结构体提供了字段信息的一些方法。
- **返回值**:例如:"INT", "VARCHAR(100)" 等 SQL 数据类型表示。
### 参数绑定
参数绑定功能主要由 Stmt 结构体支持。
#### Stmt
#### Stmt
Stmt 结构体提供了参数绑定相关功能,用于实现高效写入。
- `fn init(taos: &Q) -> RawResult<Self>`
- **接口说明**:初始化参数绑定实例。
- **参数说明**
- `taos`:数据库连接实例。
- **返回值**:成功时返回初始化的实例,失败时返回错误。
- `fn init_with_req_id(taos: &Q, req_id: u64) -> RawResult<Self>`
- **接口说明**:使用请求 ID 初始化参数绑定实例。
- **参数说明**
- `taos`:数据库连接实例。
@ -369,24 +417,28 @@ Stmt 结构体提供了参数绑定相关功能,用于实现高效写入。
- **返回值**:成功时返回初始化的实例,失败时返回错误。
- `fn prepare<S: AsRef<str>>(&mut self, sql: S) -> RawResult<&mut Self>`
- **接口说明**:准备要绑定的 SQL 语句。
- **参数说明**
- `sql`:要准备的 SQL 语句。
- **返回值**:成功时返回自身的可变引用,失败时返回错误。
- `fn set_tbname<S: AsRef<str>>(&mut self, name: S) -> RawResult<&mut Self>`
- **接口说明**:设置表名称。
- **参数说明**
- `name`:表名称。
- **返回值**:成功时返回自身的可变引用,失败时返回错误。
- `fn set_tags(&mut self, tags: &[Value]) -> RawResult<&mut Self>`
- **接口说明**:设置标签。
- **参数说明**
- `tags`:标签数组。
- **返回值**:成功时返回自身的可变引用,失败时返回错误。
- `fn set_tbname_tags<S: AsRef<str>>(&mut self, name: S, tags: &[Value]) -> RawResult<&mut Self>`
- **接口说明**:设置表名称和标签。
- **参数说明**
- `name`:表名称。
@ -394,16 +446,19 @@ Stmt 结构体提供了参数绑定相关功能,用于实现高效写入。
- **返回值**:成功时返回自身的可变引用,失败时返回错误。
- `fn bind(&mut self, params: &[ColumnView]) -> RawResult<&mut Self>`
- **接口说明**:绑定参数。
- **参数说明**
- `params`:参数数组。
- **返回值**:成功时返回自身的可变引用,失败时返回错误。
- `fn add_batch(&mut self) -> RawResult<&mut Self>`
- **接口说明**:添加批处理。
- **返回值**:成功时返回自身的可变引用,失败时返回错误。
- `fn execute(&mut self) -> RawResult<usize>`
- **接口说明**:执行语句。
- **返回值**:成功时返回受影响的行数,失败时返回错误。
@ -412,32 +467,39 @@ Stmt 结构体提供了参数绑定相关功能,用于实现高效写入。
- **返回值**:受影响的行数。
### 数据订阅
数据订阅主要涉及三个结构体,提供连接建立的 TmqBuilder 消费数据和提交偏移量的 Consumer以及偏移量 Offset。
#### TmqBuilder
同 TaosBuilder 类似TmqBuilder 提供了创建消费者对象的功能。
- `fn available_params() -> &'static [&'static str]`
- **接口说明**:获取 DSN 中可用的参数列表。
- **返回值**:返回静态字符串切片的引用,包含可用的参数名称。
- `fn from_dsn<D: IntoDsn>(dsn: D) -> RawResult<Self>`
- **接口说明**:使用 DSN 字符串创建连接,不检查连接。
- **参数说明**
- `dsn`DSN 字符串或可转换为DSN的类型。
- `dsn`DSN 字符串或可转换为 DSN 的类型。
- **返回值**:成功时返回自身类型的 `RawResult`,失败时返回错误。
- `fn client_version() -> &'static str`
- **接口说明**:获取客户端版本。
- **返回值**:返回客户端版本的静态字符串。
- `fn ping(&self, conn: &mut Self::Target) -> RawResult<()>`
- **接口说明**:检查连接是否仍然存活。
- **参数说明**
- `conn`:目标连接的可变引用。
- **返回值**:成功时返回空的 `RawResult`,失败时返回错误。
- `fn ready(&self) -> bool`
- **接口说明**:检查是否准备好连接。
- **返回值**:大多数情况下返回 `true`,表示地址准备好连接。
@ -446,27 +508,32 @@ Stmt 结构体提供了参数绑定相关功能,用于实现高效写入。
- **返回值**:成功时返回目标连接类型的 `RawResult`,失败时返回错误。
#### Consumer
Consumer 结构体提供了订阅相关的功能,包括订阅,获取消息,提交偏移量,设置偏移量等。
- `fn subscribe<T: Into<String>, I: IntoIterator<Item = T> + Send>(&mut self, topics: I) -> RawResult<()>`
- **接口说明**:订阅一系列主题。
- **参数说明**
- `topics`:要订阅的主题列表。
- **返回值**:成功时返回空的 `RawResult`,失败时返回错误。
- `fn recv_timeout(&self, timeout: Timeout) -> RawResult<Option<(Self::Offset, MessageSet<Self::Meta, Self::Data>)>>`
- **接口说明**:在指定超时时间内接收消息。
- **参数说明**
- `timeout`:超时时间。
- **返回值**:成功时返回消息,失败时返回错误。
- `fn commit(&self, offset: Self::Offset) -> RawResult<()>`
- **接口说明**:提交给定的偏移量。
- **参数说明**
- `offset`:要提交的偏移量,见下文 Offset 结构体。
- **返回值**:成功时返回空的 `RawResult`,失败时返回错误。
- `fn commit_offset(&self, topic_name: &str, vgroup_id: VGroupId, offset: i64) -> RawResult<()>`
- **接口说明**:为特定主题和分区提交偏移量。
- **参数说明**
- `topic_name`:主题名称。
@ -475,14 +542,17 @@ Consumer 结构体提供了订阅相关的功能,包括订阅,获取消息
- **返回值**:成功时返回空的 `RawResult`,失败时返回错误。
- `fn list_topics(&self) -> RawResult<Vec<String>>`
- **接口说明**:列出所有可用主题。
- **返回值**:成功时返回主题列表,失败时返回错误。
- `fn assignments(&self) -> Option<Vec<(String, Vec<Assignment>)>>`
- **接口说明**:获取当前分配的主题和分区。
- **返回值**:成功时返回分配信息,失败时返回 `None`。
- `fn offset_seek(&mut self, topic: &str, vg_id: VGroupId, offset: i64) -> RawResult<()>`
- **接口说明**:为特定主题和分区设置偏移量。
- **参数说明**
- `topic`:主题名称。
@ -491,6 +561,7 @@ Consumer 结构体提供了订阅相关的功能,包括订阅,获取消息
- **返回值**:成功时返回空的 `RawResult`,失败时返回错误。
- `fn committed(&self, topic: &str, vgroup_id: VGroupId) -> RawResult<i64>`
- **接口说明**:获取特定主题和分区的已提交偏移量。
- **参数说明**
- `topic`:主题名称。
@ -509,10 +580,12 @@ Consumer 结构体提供了订阅相关的功能,包括订阅,获取消息
Offset 结构体提供了获取当前消息所属的数据库,主题和分区信息。
- `fn database(&self) -> &str`
- **接口说明**:获取当前消息的数据库名称。
- **返回值**:数据库名称的引用。
- `fn topic(&self) -> &str`
- **接口说明**:获取当前消息的主题名称。
- **返回值**:主题名称的引用。
@ -520,8 +593,9 @@ Offset 结构体提供了获取当前消息所属的数据库,主题和分区
- **接口说明**:获取当前消息的分区 ID。
- **返回值**:分区 ID。
## 附录
## 附录
- Rust 连接器文档https://docs.rs/taos
- Rust 连接器项目地址: https://github.com/taosdata/taos-connector-rust
- deadpool 连接池: https://crates.io/crates/deadpool
- r2d2 连接池: https://crates.io/crates/r2d2
- Rust 连接器项目地址: https://github.com/taosdata/taos-connector-rust
- deadpool 连接池: https://crates.io/crates/deadpool
- r2d2 连接池: https://crates.io/crates/r2d2

View File

@ -2,60 +2,74 @@
toc_max_heading_level: 4
sidebar_label: Python
title: TDengine Python Connector
description: "taospy 是 TDengine 的官方 Python 连接器。taospy 提供了丰富的 API 使得 Python 应用可以很方便地使用 TDengine。tasopy 对 TDengine 的原生接口和 REST 接口都进行了封装, 分别对应 tasopy 的两个子模块taos 和 taosrest。除了对原生接口和 REST 接口的封装taospy 还提供了符合 Python 数据访问规范(PEP 249)的编程接口。这使得 taospy 和很多第三方工具集成变得简单,比如 SQLAlchemy 和 pandas"
description: "TDengine 数据库面向 Python 语言提供的连接器"
---
import Tabs from "@theme/Tabs";
import TabItem from "@theme/TabItem";
import RequestId from "./_request_id.mdx";
`taospy` 是 TDengine 的官方 Python 连接器。`taospy` 提供了丰富的 API 使得 Python 应用可以很方便地使用 TDengine。
`taospy` 是 TDengine 数据库面向 Python 语言提供的官方连接器,连接器对外提供对数据库写入、查询、订阅等多种访问接口。
Python 连接器的源码托管在 [GitHub](https://github.com/taosdata/taos-connector-python)。
安装连接器命令如下:
``` bash
# 原生连接和 REST 连接
pip3 install taospy
# WebSocket 连接,可选装
pip3 install taos-ws-py
```
连接器代码对外开源,源码托管在 Github [taos-connector-python](https://github.com/taosdata/taos-connector-python) 仓库。
## 连接方式
`taospy`主要提供三种形式的连接器。一般我们推荐使用 **WebSocket 连接**。
- **原生连接**,对应 `taospy` 包的 `taos` 模块。通过 TDengine 客户端驱动程序taosc原生连接 TDengine 实例支持数据写入、查询、数据订阅、schemaless 接口和参数绑定接口等功能。
- **REST 连接**,对应 `taospy` 包的 `taosrest` 模块。通过 taosAdapter 提供的 HTTP 接口连接 TDengine 实例,不支持 schemaless 和数据订阅等特性。
- **WebSocket 连接**,对应 `taos-ws-py` 包,可以选装。通过 taosAdapter 提供的 WebSocket 接口连接 TDengine 实例WebSocket 连接实现的功能集合和原生连接有少量不同。
`taospy`提供三种连接方式,我们推荐使用 **WebSocket 连接**。
- **原生连接**Python 连接器加载 TDengine 客户端驱动程序(libtaos.so/taos.dll),直接连接 TDengine 实例特点性能高速度快。功能上支持数据写入、查询、数据订阅、schemaless 接口和参数绑定接口等功能。对应 `taospy` 包的 `taos` 模块。
- **REST 连接**Python 连接器通过 `taosAdapter` 提供的 HTTP 接口连接 TDengine 实例,特点依赖小,不需要安装 TDengine 客户端驱动。功能上不支持 schemaless 和数据订阅等特性。对应 `taospy` 包的 `taosrest` 模块。
- **WebSocket 连接**Python 连接器通过 `taosAdapter` 提供的 WebSocket 接口连接 TDengine 实例,特点是兼具前两种连接的优势, 即性能高又依赖小。功能上 WebSocket 连接实现功能集合和原生连接有少量不同。对应 `taos-ws-py` 包,可以选装。
连接方式的详细介绍请参考:[连接方式](../../../develop/connect/#连接方式)
除了对原生接口和 REST 接口的封装,`taospy` 还提供了符合 [Python 数据访问规范(PEP 249)](https://peps.python.org/pep-0249/) 的编程接口。这使得 `taospy` 和很多第三方工具集成变得简单,比如 [SQLAlchemy](https://www.sqlalchemy.org/) 和 [pandas](https://pandas.pydata.org/)。
使用客户端驱动提供的原生接口直接与服务端建立的连接的方式下文中称为“原生连接”;使用 taosAdapter 提供的 REST 接口或 WebSocket 接口与服务端建立的连接的方式下文中称为“REST 连接”或“WebSocket 连接”。
使用客户端驱动提供的原生接口直接与服务端建立的连接的方式下文中称为“原生连接”;使用 `taosAdapter` 提供的 REST 接口或 WebSocket 接口与服务端建立的连接的方式下文中称为“REST 连接”或“WebSocket 连接”。
## Python 版本兼容性
支持 Python 3.0 及以上版本。
## 支持的平台
- 原生连接[支持的平台](../#支持的平台)和 TDengine 客户端支持的平台一致。
- REST 连接支持所有能运行 Python 的平台。
### 支持的功能
- 原生连接支持 TDengine 的所有核心功能, 包括: 连接管理、执行 SQL、参数绑定、订阅、无模式写入schemaless
- REST 连接支持的功能包括:连接管理、执行 SQL。 (通过执行 SQL 可以: 管理数据库、管理表和超级表、写入数据、查询数据、创建连续查询等)。
- 原生连接支持的平台和 TDengine 客户端驱动支持的平台一致。
- WebSocket/REST 连接支持所有能运行 Python 的平台。
## 历史版本
无论使用什么版本的 TDengine 都建议使用最新版本的 `taospy`。
Python Connector 历史版本(建议使用最新版本的 `taospy`
|Python Connector 版本|主要变化|
|:-------------------:|:----:|
|2.7.16|新增订阅配置 (session.timeout.ms, max.poll.interval.ms)|
|2.7.15|新增 VARBINARY 和 GEOMETRY 类型支持|
|2.7.14|修复已知问题|
|2.7.13|新增 tmq 同步提交 offset 接口|
|2.7.12|1. 新增 varbinary 类型支持STMT暂不支持 varbinary <br/> 2. query 性能提升(感谢贡献者[hadrianl](https://github.com/taosdata/taos-connector-python/pull/209)|
|2.7.9|数据订阅支持获取消费进度和重置消费进度|
|2.7.8|新增 `execute_many`|
|Python WebSocket Connector 版本|主要变化|
|:----------------------------:|:-----:|
|0.3.5|新增 VARBINARY 和 GEOMETRY 类型支持,修复已知问题|
|0.3.2|优化 WebSocket sql 查询和插入性能,修改 readme 和 文档,修复已知问题|
|0.2.9|已知问题修复|
|0.2.5|1. 数据订阅支持获取消费进度和重置消费进度 <br/> 2. 支持 schemaless <br/> 3. 支持 STMT|
|0.2.4|数据订阅新增取消订阅方法|
| Python Connector 版本 | 主要变化 | TDengine 版本 |
| -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------- |
| 2.7.18 | 支持 Apache Superset BI 产品 | - |
| 2.7.16 | 新增订阅配置 (session.timeout.ms, max.poll.interval.ms) | - |
| 2.7.15 | 新增 VARBINARY 和 GEOMETRY 类型支持 | - |
| 2.7.14 | 修复已知问题 | - |
| 2.7.13 | 新增 tmq 同步提交 offset 接口 | - |
| 2.7.12 | 1. 新增 varbinary 类型支持STMT暂不支持 varbinary <br/> 2. query 性能提升(感谢贡献者[hadrianl](https://github.com/taosdata/taos-connector-python/pull/209) | 3.1.1.2 及更高版本 |
| 2.7.9 | 数据订阅支持获取消费进度和重置消费进度 | 3.0.2.6 及更高版本 |
| 2.7.8 | 新增 `execute_many` | 3.0.0.0 及更高版本 |
WebSocket Connector 历史版本:
| WebSocket Connector 版本 | 主要变化 | TDengine 版本 |
| ----------------------- | ------------------------------------------------------------------------------------ | ----------------- |
| 0.3.2 | 优化 WebSocket sql 查询和插入性能,修改 readme 和 文档,修复已知问题 | 3.2.3.0 及更高版本 |
| 0.2.9 | 已知问题修复 | - |
| 0.2.5 | 1. 数据订阅支持获取消费进度和重置消费进度 <br/> 2. 支持 schemaless <br/> 3. 支持 STMT | - |
| 0.2.4 | 数据订阅新增取消订阅方法 | 3.0.5.0 及更高版本 |
## 处理异常
@ -67,17 +81,17 @@ Python 连接器可能会产生 4 种异常:
- 数据订阅异常
- TDengine 其他功能模块的报错,请参考 [错误码](../../../reference/error-code)
|Error Type|Description|Suggested Actions|
|:--------:|:---------:|:---------------:|
|InterfaceError|taosc 版本太低,不支持所使用的接口|请检查 TDengine 客户端版本|
|ConnectionError|数据库链接错误|请检查 TDengine 服务端状态和连接参数|
|DatabaseError|数据库错误|请检查 TDengine 服务端版本,并将 Python 连接器升级到最新版|
|OperationalError|操作错误|API 使用错误,请检查代码|
|ProgrammingError|接口调用错误|请检查提交的数据是否正确|
|StatementError|stmt 相关异常|请检查绑定参数与 sql 是否匹配|
|ResultError|操作数据错误|请检查操作的数据与数据库中的数据类型是否匹配|
|SchemalessError|schemaless 相关异常|请检查数据格式及对应的协议类型是否正确|
|TmqError|tmq 相关异常|请检查 Topic 及 consumer 配置是否正确|
| Error Type | Description | Suggested Actions |
| :--------------- | :--------------------------------- | :--------------------------------------------------------- |
| InterfaceError | taosc 版本太低,不支持所使用的接口 | 请检查 TDengine 客户端版本 |
| ConnectionError | 数据库链接错误 | 请检查 TDengine 服务端状态和连接参数 |
| DatabaseError | 数据库错误 | 请检查 TDengine 服务端版本,并将 Python 连接器升级到最新版 |
| OperationalError | 操作错误 | API 使用错误,请检查代码 |
| ProgrammingError | 接口调用错误 | 请检查提交的数据是否正确 |
| StatementError | stmt 相关异常 | 请检查绑定参数与 sql 是否匹配 |
| ResultError | 操作数据错误 | 请检查操作的数据与数据库中的数据类型是否匹配 |
| SchemalessError | schemaless 相关异常 | 请检查数据格式及对应的协议类型是否正确 |
| TmqError | tmq 相关异常 | 请检查 Topic 及 consumer 配置是否正确 |
Python 中通常通过 try-expect 处理异常,异常处理相关请参考 [Python 错误和异常文档](https://docs.python.org/3/tutorial/errors.html)。
TDengine 其他功能模块的报错,请参考 [错误码](../../../reference/error-code)
@ -92,32 +106,32 @@ Python Connector 的所有数据库操作如果出现异常,都会直接抛出
TDengine 目前支持时间戳、数字、字符、布尔类型,与 Python 对应类型转换如下:
|TDengine DataType|Python DataType|
|:---------------:|:-------------:|
|TIMESTAMP|datetime|
|INT|int|
|BIGINT|int|
|FLOAT|float|
|DOUBLE|int|
|SMALLINT|int|
|TINYINT|int|
|BOOL|bool|
|BINARY|str|
|NCHAR|str|
|JSON|str|
|GEOMETRY|bytearray|
|VARBINARY|bytearray|
| TDengine DataType | Python DataType |
| :---------------- | :-------------- |
| TIMESTAMP | datetime |
| INT | int |
| BIGINT | int |
| FLOAT | float |
| DOUBLE | int |
| SMALLINT | int |
| TINYINT | int |
| BOOL | bool |
| BINARY | str |
| NCHAR | str |
| JSON | str |
| GEOMETRY | bytearray |
| VARBINARY | bytearray |
## 示例程序汇总
| 示例程序链接 | 示例程序内容 |
| ------------------------------------------------------------------------------------------------------------- | ----------------------- |
| [bind_multi.py](https://github.com/taosdata/taos-connector-python/blob/main/examples/bind-multi.py) | 参数绑定, 一次绑定多行 |
| [bind_row.py](https://github.com/taosdata/taos-connector-python/blob/main/examples/bind-row.py) | 参数绑定,一次绑定一行 |
| [insert_lines.py](https://github.com/taosdata/taos-connector-python/blob/main/examples/insert-lines.py) | InfluxDB 行协议写入 |
| [json_tag.py](https://github.com/taosdata/taos-connector-python/blob/main/examples/json-tag.py) | 使用 JSON 类型的标签 |
| [tmq_consumer.py](https://github.com/taosdata/taos-connector-python/blob/main/examples/tmq_consumer.py) | tmq 订阅 |
| [native_all_type_query.py](https://github.com/taosdata/taos-connector-python/blob/main/examples/native_all_type_query.py) | 支持全部类型示例 |
| [native_all_type_stmt.py](https://github.com/taosdata/taos-connector-python/blob/main/examples/native_all_type_stmt.py) | 参数绑定支持全部类型示例 |
| 示例程序链接 | 示例程序内容 |
| ------------------------------------------------------------------------------------------------------------------------- | ------------------------ |
| [bind_multi.py](https://github.com/taosdata/taos-connector-python/blob/main/examples/bind-multi.py) | 参数绑定, 一次绑定多行 |
| [bind_row.py](https://github.com/taosdata/taos-connector-python/blob/main/examples/bind-row.py) | 参数绑定,一次绑定一行 |
| [insert_lines.py](https://github.com/taosdata/taos-connector-python/blob/main/examples/insert-lines.py) | InfluxDB 行协议写入 |
| [json_tag.py](https://github.com/taosdata/taos-connector-python/blob/main/examples/json-tag.py) | 使用 JSON 类型的标签 |
| [tmq_consumer.py](https://github.com/taosdata/taos-connector-python/blob/main/examples/tmq_consumer.py) | tmq 订阅 |
| [native_all_type_query.py](https://github.com/taosdata/taos-connector-python/blob/main/examples/native_all_type_query.py) | 支持全部类型示例 |
| [native_all_type_stmt.py](https://github.com/taosdata/taos-connector-python/blob/main/examples/native_all_type_stmt.py) | 参数绑定支持全部类型示例 |
示例程序源码请参考:

View File

@ -9,26 +9,24 @@ import TabItem from "@theme/TabItem";
import RequestId from "./_request_id.mdx";
`@tdengine/websocket` 是 TDengine 的官方 Node.js 语言连接器。Node.js 开发人员可以通过它开发存取 TDengine 数据库的应用软件。
Node.js 连接器源码托管在 [GitHub](https://github.com/taosdata/taos-connector-node/tree/main)。
## 连接方式
## Node.js 版本兼容性
Node.js 连接器目前仅支持 WebSocket 连接器, 其通过 taosAdapter 提供的 WebSocket 接口连接 TDengine 实例。
连接方式的详细介绍请参考:[连接方式](../../../develop/connect/#连接方式)
支持 Node.js 14 及以上版本。
## 支持的平台
支持 Node.js 14及以上版本。
支持所有能运行 Node.js 的平台。
## 版本历史
| Node.js 连接器 版本 | 主要变化 | TDengine 版本 |
| :------------------: | :----------------------: | :----------------: |
| 3.1.2 | 对数据协议和解析进行了优化,性能得到大幅提升| 3.3.2.0 及更高版本 |
| 3.1.1 | 优化了数据传输性能 | 3.3.2.0 及更高版本 |
| 3.1.0 | 新版本发布,支持 WebSocket 连接 | 3.2.0.0 及更高版本 |
| ------------------| ----------------------| ----------------|
| 3.1.2 | 对数据协议和解析进行了优化,性能得到大幅提升| - |
| 3.1.1 | 优化了数据传输性能 | 3.3.2.0 及更高版本 |
| 3.1.0 | 新版本发布,支持 WebSocket 连接 | 3.2.0.0 及更高版本 |
## 处理异常

View File

@ -10,35 +10,25 @@ import RequestId from "./_request_id.mdx";
`TDengine.Connector` 是 TDengine 提供的 C# 语言连接器。C# 开发人员可以通过它开发存取 TDengine 集群数据的 C# 应用软件。
## 连接方式
## .NET 版本兼容性
`TDengine.Connector` 提供两种形式的连接器
* **原生连接**,通过 TDengine 客户端驱动程序taosc原生连接 TDengine 实例支持数据写入、查询、数据订阅、schemaless 接口和参数绑定接口等功能。
* **WebSocket 连接**,通过 taosAdapter 提供的 WebSocket 接口连接 TDengine 实例WebSocket 连接实现的功能集合和原生连接有少量不同。(自 v3.0.1 起)
连接方式的详细介绍请参考:[连接方式](../../../develop/connect/#连接方式)
## 兼容性
* `TDengine.Connector` 3.1.0 版本进行了完整的重构,不再兼容 3.0.2 及以前版本。3.0.2 文档请参考 [nuget](https://www.nuget.org/packages/TDengine.Connector/3.0.2)
* `TDengine.Connector` 3.x 不兼容 TDengine 2.x如果在运行 TDengine 2.x 版本的环境下需要使用 C# 连接器请使用 TDengine.Connector 的 1.x 版本。
- .NET Framework 4.6 及以上版本。
- .NET 5.0 及以上版本。
## 支持的平台
支持的平台和 TDengine 客户端驱动支持的平台一致。
- 原生连接支持的平台和 TDengine 客户端驱动支持的平台一致。
- WebSocket 连接支持所有能运行 .NET 运行时的平台。
:::warning
TDengine 不再支持 32 位 Windows 平台。
:::
## 版本历史
## 版本支持
| **Connector 版本** | **TDengine 版本** | **主要功能** |
|------------------|------------------|----------------------------|
| 3.1.3 | 3.2.1.0/3.1.1.18 | 支持 WebSocket 自动重连 |
| 3.1.2 | 3.2.1.0/3.1.1.18 | 修复 schemaless 资源释放 |
| 3.1.1 | 3.2.1.0/3.1.1.18 | 支持 varbinary 和 geometry 类型 |
| 3.1.0 | 3.2.1.0/3.1.1.18 | WebSocket 使用原生实现 |
| Connector 版本 | 主要变化 | TDengine 版本 |
|:-------------|:---------------------------|:--------------|
| 3.1.4 | 提升 websocket 查询和写入性能 | 3.3.2.0 及更高版本 |
| 3.1.3 | 支持 WebSocket 自动重连 | - |
| 3.1.2 | 修复 schemaless 资源释放 | - |
| 3.1.1 | 支持 varbinary 和 geometry 类型 | - |
| 3.1.0 | WebSocket 使用原生实现 | 3.2.1.0 及更高版本 |
## 处理异常

View File

@ -15,7 +15,8 @@ TDengine ODBC 提供 64 位 和 32 位 两种驱动程序。但 32 位仅企业
想更多了解 TDengine 时序时序数据库的使用,可访问 [TDengine官方文档](https://docs.taosdata.com/intro/)。
## ODBC 版本兼容性
- 支持 ODBC 3.8 及以前所有版本。
支持 ODBC 所有版本
## 安装
@ -106,18 +107,18 @@ TDengine ODBC 支持两种连接 TDengine 数据库方式WebSocket 连接与
## 支持的平台
原生连接方式支持的平台和 TDengine Windows X64版 客户端驱动支持的平台一致。
WebSocket 连接方式除此之外还支持 Windows X64系统上运行的 32 位应用程序上使用。
- 原生连接方式支持的平台和 TDengine Windows X64版 客户端驱动支持的平台一致。
- WebSocket 连接方式除此之外还支持 Windows X64系统上运行的 32 位应用程序上使用。
## 版本历史
| taos_odbc 版本 | 主要变化 | TDengine 版本 |
| :----------- | :-------------------------------------------------------------------------------------------------- | :---------------- |
| v1.1.0 | 1. 支持视图功能;<br/>2. 支持 VARBINARY/GEOMETRY 数据类型;<br/>3. 支持 ODBC 32 位 WebSocket 连接方式(仅企业版支持);<br/>4. 支持 ODBC 数据源配置对话框设置对工业软件 KingSCADA、Kepware 等的兼容性适配选项(仅企业版支持); | 3.3.3.0及更高版本 |
| v1.0.2 | 支持 CP1252 字符编码; | 3.2.3.0及更高版本 |
| ----------- | -------------------------------------------------------------------------------------------------- | ---------------- |
| v1.1.0 | 1. 支持视图功能;<br/>2. 支持 VARBINARY/GEOMETRY 数据类型;<br/>3. 支持 ODBC 32 位 WebSocket 连接方式(仅企业版支持);<br/>4. 支持 ODBC 数据源配置对话框设置对工业软件 KingSCADA、Kepware 等的兼容性适配选项(仅企业版支持); | 3.3.3.0 及更高版本 |
| v1.0.2 | 支持 CP1252 字符编码; | 3.2.3.0 及更高版本 |
| v1.0.1 | 1. 支持 DSN 设置 BI 模式,在 BI 模式下 TDengine 数据库不返回系统数据库和超级表子表信息;<br/>2. 重构字符集转换模块,提升读写性能;<br/>3. ODBC 数据源配置对话框中默认修改默认连接方式为“WebSocket”<br/>4. ODBC 数据源配置对话框增加“测试连接”控件;<br/>5. ODBC 数据源配置支持中文/英文界面; | - |
| v1.0.0.0 | 发布初始版本支持与Tdengine数据库交互以读写数据具体请参考“API 参考”一节 | 3.2.2.0及更高版本 |
| v1.0.0.0 | 发布初始版本支持与Tdengine数据库交互以读写数据具体请参考“API 参考”一节 | 3.2.2.0 及更高版本 |
## 数据类型映射

Binary file not shown.

Before

Width:  |  Height:  |  Size: 179 KiB

After

Width:  |  Height:  |  Size: 125 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 117 KiB

After

Width:  |  Height:  |  Size: 132 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 133 KiB

After

Width:  |  Height:  |  Size: 79 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 105 KiB

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

After

Width:  |  Height:  |  Size: 264 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 52 KiB

After

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 96 KiB

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 133 KiB

After

Width:  |  Height:  |  Size: 87 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 163 KiB

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 88 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 282 KiB

After

Width:  |  Height:  |  Size: 159 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 75 KiB

After

Width:  |  Height:  |  Size: 105 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 148 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 152 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 103 KiB

After

Width:  |  Height:  |  Size: 244 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 194 KiB

After

Width:  |  Height:  |  Size: 203 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 106 KiB

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 155 KiB

After

Width:  |  Height:  |  Size: 130 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 127 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 139 KiB

View File

@ -276,11 +276,15 @@ TDinsight插件中展示的数据是通过taosKeeper和taosAdapter服务收集
### 30 为什么开源版 TDengine 的主进程会建立一个与公网的连接?
这个连接只会上报不涉及任何用户数据的最基本信息用于官方了解产品在世界范围内的分布情况进而优化产品提升用户体验具体采集项目为集群名、操作系统版本、cpu信息等。
该特性为可选配置项,在开源版中默认开启,具体参数为 telemetryReporting , 在官方文档中有做说明,链接如下:
https://docs.taosdata.com/reference/components/taosd/#%E7%9B%91%E6%8E%A7%E7%9B%B8%E5%85%B3
该特性为可选配置项,在开源版中默认开启,具体参数为 telemetryReporting , 在官方文档中有做说明,链接如下:[参数简介](https://docs.taosdata.com/reference/components/taosd/#%E7%9B%91%E6%8E%A7%E7%9B%B8%E5%85%B3)
您可以随时关闭该参数只需要在taos.cfg 中修改telemetryReporting为 0然后重启数据库服务即可。
代码位于:https://github.com/taosdata/TDengine/blob/62e609c558deb764a37d1a01ba84bc35115a85a4/source/dnode/mnode/impl/src/mndTelem.c
此外,对于安全性要求极高的企业版 TDengine Enterprise 来说,此参数不会工作。
代码位于:[点击此处](https://github.com/taosdata/TDengine/blob/62e609c558deb764a37d1a01ba84bc35115a85a4/source/dnode/mnode/impl/src/mndTelem.c)
此外,对于安全性要求极高的企业版 TDengine Enterprise 来说,此参数不会工作。
### 31 第一次连接集群时遇到“Sync leader is unreachable”怎么办
报这个错说明第一次向集群的连接是成功的但第一次访问的IP不是mnode的leader节点客户端试图与leader建立连接时发生错误。客户端通过EP也就是指定的fqdn与端口号寻找leader节点常见的报错原因有两个
@ -297,4 +301,4 @@ https://docs.taosdata.com/reference/components/taosd/#%E7%9B%91%E6%8E%A7%E7%9B%B
问题影响:服务器重启后,原有数据库丢失(注:并非真正丢失,只是原有的数据磁盘未挂载,暂时看不到)且集群 ID 发生变化,导致无法访问原有数据库。对于企业版用户,如果已针对集群 ID 进行授权,还会发现集群服务器的机器码未变,但原有的授权已失效。如果未针对该问题进行监控或者未及时发现并进行处理,则用户不会注意到原有数据库已经丢失,从而造成损失,增加运维成本。
问题解决:应在 fstab 文件中配置 dataDir 目录的自动挂载,确保 dataDir 始终指向预期的挂载点和目录,此时,再重启服务器,会找回原有的数据库和集群。在后续的版本中,我们将开发一个功能,使 taosd 在检测到启动前后 dataDir 发生变化时,在启动阶段退出,同时提供相应的错误提示。
问题解决:应在 fstab 文件中配置 dataDir 目录的自动挂载,确保 dataDir 始终指向预期的挂载点和目录,此时,再重启服务器,会找回原有的数据库和集群。在后续的版本中,我们将开发一个功能,使 taosd 在检测到启动前后 dataDir 发生变化时,在启动阶段退出,同时提供相应的错误提示。

View File

@ -111,14 +111,14 @@ typedef struct TAOS_FIELD_E {
int32_t bytes;
} TAOS_FIELD_E;
typedef struct TAOS_FIELD_STB {
typedef struct TAOS_FIELD_ALL {
char name[65];
int8_t type;
uint8_t precision;
uint8_t scale;
int32_t bytes;
uint8_t field_type;
} TAOS_FIELD_STB;
} TAOS_FIELD_ALL;
#ifdef WINDOWS
#define DLL_EXPORT __declspec(dllexport)
@ -250,10 +250,8 @@ DLL_EXPORT int taos_stmt2_bind_param(TAOS_STMT2 *stmt, TAOS_STMT2_BINDV
DLL_EXPORT int taos_stmt2_exec(TAOS_STMT2 *stmt, int *affected_rows);
DLL_EXPORT int taos_stmt2_close(TAOS_STMT2 *stmt);
DLL_EXPORT int taos_stmt2_is_insert(TAOS_STMT2 *stmt, int *insert);
DLL_EXPORT int taos_stmt2_get_fields(TAOS_STMT2 *stmt, TAOS_FIELD_T field_type, int *count, TAOS_FIELD_E **fields);
DLL_EXPORT int taos_stmt2_get_stb_fields(TAOS_STMT2 *stmt, int *count, TAOS_FIELD_STB **fields);
DLL_EXPORT void taos_stmt2_free_fields(TAOS_STMT2 *stmt, TAOS_FIELD_E *fields);
DLL_EXPORT void taos_stmt2_free_stb_fields(TAOS_STMT2 *stmt, TAOS_FIELD_STB *fields);
DLL_EXPORT int taos_stmt2_get_fields(TAOS_STMT2 *stmt, int *count, TAOS_FIELD_ALL **fields);
DLL_EXPORT void taos_stmt2_free_fields(TAOS_STMT2 *stmt, TAOS_FIELD_ALL *fields);
DLL_EXPORT TAOS_RES *taos_stmt2_result(TAOS_STMT2 *stmt);
DLL_EXPORT char *taos_stmt2_error(TAOS_STMT2 *stmt);

View File

@ -188,6 +188,7 @@ void tCleanupStreamHbMsg(SStreamHbMsg* pMsg);
typedef struct {
SMsgHead head;
int32_t msgId;
SEpSet mndEpset;
} SMStreamHbRspMsg;
int32_t tEncodeStreamHbRsp(SEncoder* pEncoder, const SMStreamHbRspMsg* pRsp);

View File

@ -85,7 +85,7 @@ extern int32_t tsQueryConcurrentTaskNum;
extern int32_t tsSingleQueryMaxMemorySize;
extern int8_t tsQueryUseMemoryPool;
extern int8_t tsMemPoolFullFunc;
//extern int32_t tsQueryBufferPoolSize;
// extern int32_t tsQueryBufferPoolSize;
extern int32_t tsMinReservedMemorySize;
extern int64_t tsCurrentAvailMemorySize;
extern int8_t tsNeedTrim;
@ -283,7 +283,7 @@ extern int32_t tsS3MigrateIntervalSec;
extern bool tsS3MigrateEnabled;
extern int32_t tsGrantHBInterval;
extern int32_t tsUptimeInterval;
extern bool tsUpdateCacheBatch;
extern bool tsDisableStream;
extern int64_t tsStreamBufferSize;
extern int tsStreamAggCnt;

View File

@ -62,7 +62,7 @@ typedef struct SMetaEntry {
struct {
int64_t btime;
int32_t ttlDays;
int32_t commentLen;
int32_t commentLen; // not include '\0'
char* comment;
tb_uid_t suid;
uint8_t* pTags;

View File

@ -150,7 +150,7 @@ int32_t qBindStmtSingleColValue(void* pBlock, SArray* pCols, TAOS_MULTI_BIND* bi
int32_t colIdx, int32_t rowNum, void* charsetCxt);
int32_t qBuildStmtColFields(void* pDataBlock, int32_t* fieldNum, TAOS_FIELD_E** fields);
int32_t qBuildStmtStbColFields(void* pBlock, void* boundTags, bool hasCtbName, int32_t* fieldNum,
TAOS_FIELD_STB** fields);
TAOS_FIELD_ALL** fields);
int32_t qBuildStmtTagFields(void* pBlock, void* boundTags, int32_t* fieldNum, TAOS_FIELD_E** fields);
int32_t qBindStmtTagsValue(void* pBlock, void* boundTags, int64_t suid, const char* sTableName, char* tName,
TAOS_MULTI_BIND* bind, char* msgBuf, int32_t msgBufLen, void* charsetCxt);

View File

@ -17,6 +17,7 @@
#define _TD_UTIL_HTTP_H_
#include "os.h"
#include "tdef.h"
#include "tref.h"
#ifdef __cplusplus
@ -35,6 +36,21 @@ int32_t taosSendHttpReportByChan(const char* server, const char* uri, uint16_t p
EHttpCompFlag flag, int64_t chanId, const char* qid);
void taosDestroyHttpChan(int64_t chanId);
int32_t taosSendRecvHttpReportWithQID(const char* server, const char* uri, uint16_t port, char* pCont, int32_t contLen,
EHttpCompFlag flag, const char* qid, int64_t recvBufId);
typedef struct {
char defaultAddr[256 + 1];
char cachedAddr[256 + 1];
int64_t recvBufRid;
} STelemAddrMgmt;
int32_t taosTelemetryMgtInit(STelemAddrMgmt* mgt, char* defaultAddr);
void taosTelemetryDestroy(STelemAddrMgmt* mgt);
// not safe for multi-thread, should be called in the same thread
int32_t taosSendTelemReport(STelemAddrMgmt* mgt, const char* uri, uint16_t port, char* pCont, int32_t contLen,
EHttpCompFlag flag);
#ifdef __cplusplus
}
#endif

View File

@ -36,6 +36,7 @@ extern "C" {
#define WAL_FILE_LEN (WAL_PATH_LEN + 32)
#define WAL_MAGIC 0xFAFBFCFDF4F3F2F1ULL
#define WAL_SCAN_BUF_SIZE (1024 * 1024 * 3)
#define WAL_JSON_BUF_SIZE 30
typedef enum {
TAOS_WAL_SKIP = 0,

View File

@ -24,7 +24,7 @@ extern "C" {
#endif
int32_t taosEnvNameToCfgName(const char *envNameStr, char *cfgNameStr, int32_t cfgNameMaxLen);
int32_t taosEnvToCfg(const char *envStr, char *cfgStr);
int32_t taosEnvToCfg(const char *envStr, char *cfgStr,int32_t cfgStrLen);
#ifdef __cplusplus
}

View File

@ -122,10 +122,10 @@ static FORCE_INLINE int32_t taosGetTbHashVal(const char *tbname, int32_t tblen,
* only in very hot code paths. Misuse or abuse can lead to performance degradation.
*/
#if __GNUC__ >= 3
#define LIKELY(x) __builtin_expect((x) != 0, 1)
#define LIKELY(x) __builtin_expect((x) != 0, 1)
#define UNLIKELY(x) __builtin_expect((x) != 0, 0)
#else
#define LIKELY(x) ((x) != 0)
#define LIKELY(x) ((x) != 0)
#define UNLIKELY(x) ((x) != 0)
#endif

View File

@ -223,7 +223,7 @@ int stmtSetTbTags2(TAOS_STMT2 *stmt, TAOS_STMT2_BIND *tags);
int stmtBindBatch2(TAOS_STMT2 *stmt, TAOS_STMT2_BIND *bind, int32_t colIdx);
int stmtGetTagFields2(TAOS_STMT2 *stmt, int *nums, TAOS_FIELD_E **fields);
int stmtGetColFields2(TAOS_STMT2 *stmt, int *nums, TAOS_FIELD_E **fields);
int stmtGetStbColFields2(TAOS_STMT2 *stmt, int *nums, TAOS_FIELD_STB **fields);
int stmtGetStbColFields2(TAOS_STMT2 *stmt, int *nums, TAOS_FIELD_ALL **fields);
int stmtGetParamNum2(TAOS_STMT2 *stmt, int *nums);
int stmtGetParamTbName(TAOS_STMT2 *stmt, int *nums);
int stmtIsInsert2(TAOS_STMT2 *stmt, int *insert);

View File

@ -172,7 +172,8 @@ static int32_t generateWriteSlowLog(STscObj *pTscObj, SRequestObj *pRequest, int
ENV_JSON_FALSE_CHECK(cJSON_AddItemToObject(json, "type", cJSON_CreateNumber(reqType)));
ENV_JSON_FALSE_CHECK(cJSON_AddItemToObject(
json, "rows_num", cJSON_CreateNumber(pRequest->body.resInfo.numOfRows + pRequest->body.resInfo.totalRows)));
if (pRequest->sqlstr != NULL && strlen(pRequest->sqlstr) > pTscObj->pAppInfo->serverCfg.monitorParas.tsSlowLogMaxLen) {
if (pRequest->sqlstr != NULL &&
strlen(pRequest->sqlstr) > pTscObj->pAppInfo->serverCfg.monitorParas.tsSlowLogMaxLen) {
char tmp = pRequest->sqlstr[pTscObj->pAppInfo->serverCfg.monitorParas.tsSlowLogMaxLen];
pRequest->sqlstr[pTscObj->pAppInfo->serverCfg.monitorParas.tsSlowLogMaxLen] = '\0';
ENV_JSON_FALSE_CHECK(cJSON_AddItemToObject(json, "sql", cJSON_CreateString(pRequest->sqlstr)));
@ -802,6 +803,7 @@ void stopAllQueries(SRequestObj *pRequest) {
void crashReportThreadFuncUnexpectedStopped(void) { atomic_store_32(&clientStop, -1); }
static void *tscCrashReportThreadFp(void *param) {
int32_t code = 0;
setThreadName("client-crashReport");
char filepath[PATH_MAX] = {0};
(void)snprintf(filepath, sizeof(filepath), "%s%s.taosCrashLog", tsLogDir, TD_DIRSEP);
@ -822,6 +824,12 @@ static void *tscCrashReportThreadFp(void *param) {
if (-1 != atomic_val_compare_exchange_32(&clientStop, -1, 0)) {
return NULL;
}
STelemAddrMgmt mgt;
code = taosTelemetryMgtInit(&mgt, tsTelemServer);
if (code) {
tscError("failed to init telemetry management, code:%s", tstrerror(code));
return NULL;
}
while (1) {
if (clientStop > 0) break;
@ -832,7 +840,7 @@ static void *tscCrashReportThreadFp(void *param) {
taosReadCrashInfo(filepath, &pMsg, &msgLen, &pFile);
if (pMsg && msgLen > 0) {
if (taosSendHttpReport(tsTelemServer, tsClientCrashReportUri, tsTelemPort, pMsg, msgLen, HTTP_FLAT) != 0) {
if (taosSendTelemReport(&mgt, tsClientCrashReportUri, tsTelemPort, pMsg, msgLen, HTTP_FLAT) != 0) {
tscError("failed to send crash report");
if (pFile) {
taosReleaseCrashLogFile(pFile, false);
@ -866,6 +874,7 @@ static void *tscCrashReportThreadFp(void *param) {
taosMsleep(sleepTime);
loopTimes = 0;
}
taosTelemetryDestroy(&mgt);
clientStop = -2;
return NULL;
@ -1107,7 +1116,7 @@ int taos_options_imp(TSDB_OPTION option, const char *str) {
*/
uint64_t generateRequestId() {
static uint32_t hashId = 0;
static int32_t requestSerialId = 0;
static int32_t requestSerialId = 0;
if (hashId == 0) {
int32_t code = taosGetSystemUUIDU32(&hashId);

View File

@ -109,8 +109,10 @@ static timezone_t setConnnectionTz(const char* val){
time_t tx1 = taosGetTimestampSec();
char output[TD_TIMEZONE_LEN] = {0};
taosFormatTimezoneStr(tx1, val, tz, output);
code = taosHashPut(pTimezoneNameMap, &tz, sizeof(timezone_t), output, strlen(output) + 1);
code = taosFormatTimezoneStr(tx1, val, tz, output);
if (code == 0){
code = taosHashPut(pTimezoneNameMap, &tz, sizeof(timezone_t), output, strlen(output) + 1);
}
if (code != 0){
tscError("failed to put timezone %s to map", val);
}
@ -122,23 +124,23 @@ END:
static int32_t setConnectionOption(TAOS *taos, TSDB_OPTION_CONNECTION option, const char* val){
if (taos == NULL) {
return TSDB_CODE_INVALID_PARA;
return terrno = TSDB_CODE_INVALID_PARA;
}
#ifdef WINDOWS
if (option == TSDB_OPTION_CONNECTION_TIMEZONE){
return TSDB_CODE_NOT_SUPPORTTED_IN_WINDOWS;
return terrno = TSDB_CODE_NOT_SUPPORTTED_IN_WINDOWS;
}
#endif
if (option < TSDB_OPTION_CONNECTION_CLEAR || option >= TSDB_MAX_OPTIONS_CONNECTION){
return TSDB_CODE_INVALID_PARA;
return terrno = TSDB_CODE_INVALID_PARA;
}
int32_t code = taos_init();
// initialize global config
if (code != 0) {
return code;
return terrno = code;
}
STscObj *pObj = acquireTscObj(*(int64_t *)taos);
@ -208,7 +210,7 @@ static int32_t setConnectionOption(TAOS *taos, TSDB_OPTION_CONNECTION option, co
END:
releaseTscObj(*(int64_t *)taos);
return code;
return terrno = code;
}
int taos_options_connection(TAOS *taos, TSDB_OPTION_CONNECTION option, const void *arg, ...){
@ -2248,29 +2250,29 @@ int taos_stmt2_is_insert(TAOS_STMT2 *stmt, int *insert) {
return stmtIsInsert2(stmt, insert);
}
int taos_stmt2_get_fields(TAOS_STMT2 *stmt, TAOS_FIELD_T field_type, int *count, TAOS_FIELD_E **fields) {
if (stmt == NULL || count == NULL) {
tscError("NULL parameter for %s", __FUNCTION__);
terrno = TSDB_CODE_INVALID_PARA;
return terrno;
}
// int taos_stmt2_get_fields(TAOS_STMT2 *stmt, TAOS_FIELD_T field_type, int *count, TAOS_FIELD_E **fields) {
// if (stmt == NULL || count == NULL) {
// tscError("NULL parameter for %s", __FUNCTION__);
// terrno = TSDB_CODE_INVALID_PARA;
// return terrno;
// }
if (field_type == TAOS_FIELD_COL) {
return stmtGetColFields2(stmt, count, fields);
} else if (field_type == TAOS_FIELD_TAG) {
return stmtGetTagFields2(stmt, count, fields);
} else if (field_type == TAOS_FIELD_QUERY) {
return stmtGetParamNum2(stmt, count);
} else if (field_type == TAOS_FIELD_TBNAME) {
return stmtGetParamTbName(stmt, count);
} else {
tscError("invalid parameter for %s", __FUNCTION__);
terrno = TSDB_CODE_INVALID_PARA;
return terrno;
}
}
// if (field_type == TAOS_FIELD_COL) {
// return stmtGetColFields2(stmt, count, fields);
// } else if (field_type == TAOS_FIELD_TAG) {
// return stmtGetTagFields2(stmt, count, fields);
// } else if (field_type == TAOS_FIELD_QUERY) {
// return stmtGetParamNum2(stmt, count);
// } else if (field_type == TAOS_FIELD_TBNAME) {
// return stmtGetParamTbName(stmt, count);
// } else {
// tscError("invalid parameter for %s", __FUNCTION__);
// terrno = TSDB_CODE_INVALID_PARA;
// return terrno;
// }
// }
int taos_stmt2_get_stb_fields(TAOS_STMT2 *stmt, int *count, TAOS_FIELD_STB **fields) {
int taos_stmt2_get_fields(TAOS_STMT2 *stmt, int *count, TAOS_FIELD_ALL **fields) {
if (stmt == NULL || count == NULL) {
tscError("NULL parameter for %s", __FUNCTION__);
terrno = TSDB_CODE_INVALID_PARA;
@ -2292,13 +2294,7 @@ int taos_stmt2_get_stb_fields(TAOS_STMT2 *stmt, int *count, TAOS_FIELD_STB **fie
return stmtGetStbColFields2(stmt, count, fields);
}
void taos_stmt2_free_fields(TAOS_STMT2 *stmt, TAOS_FIELD_E *fields) {
(void)stmt;
if (!fields) return;
taosMemoryFree(fields);
}
DLL_EXPORT void taos_stmt2_free_stb_fields(TAOS_STMT2 *stmt, TAOS_FIELD_STB *fields) {
DLL_EXPORT void taos_stmt2_free_fields(TAOS_STMT2 *stmt, TAOS_FIELD_ALL *fields) {
(void)stmt;
if (!fields) return;
taosMemoryFree(fields);

View File

@ -39,7 +39,7 @@ static FORCE_INLINE int32_t stmtAllocQNodeFromBuf(STableBufInfo* pTblBuf, void**
}
static bool stmtDequeue(STscStmt2* pStmt, SStmtQNode** param) {
while (0 == atomic_load_64(&pStmt->queue.qRemainNum)) {
while (0 == atomic_load_64((int64_t*)&pStmt->queue.qRemainNum)) {
taosUsleep(1);
return false;
}
@ -53,7 +53,7 @@ static bool stmtDequeue(STscStmt2* pStmt, SStmtQNode** param) {
*param = node;
(void)atomic_sub_fetch_64(&pStmt->queue.qRemainNum, 1);
(void)atomic_sub_fetch_64((int64_t*)&pStmt->queue.qRemainNum, 1);
return true;
}
@ -63,7 +63,7 @@ static void stmtEnqueue(STscStmt2* pStmt, SStmtQNode* param) {
pStmt->queue.tail = param;
pStmt->stat.bindDataNum++;
(void)atomic_add_fetch_64(&pStmt->queue.qRemainNum, 1);
(void)atomic_add_fetch_64((int64_t*)&pStmt->queue.qRemainNum, 1);
}
static int32_t stmtCreateRequest(STscStmt2* pStmt) {
@ -1086,7 +1086,7 @@ static int stmtFetchColFields2(STscStmt2* pStmt, int32_t* fieldNum, TAOS_FIELD_E
return TSDB_CODE_SUCCESS;
}
static int stmtFetchStbColFields2(STscStmt2* pStmt, int32_t* fieldNum, TAOS_FIELD_STB** fields) {
static int stmtFetchStbColFields2(STscStmt2* pStmt, int32_t* fieldNum, TAOS_FIELD_ALL** fields) {
if (pStmt->errCode != TSDB_CODE_SUCCESS) {
return pStmt->errCode;
}
@ -1112,6 +1112,7 @@ static int stmtFetchStbColFields2(STscStmt2* pStmt, int32_t* fieldNum, TAOS_FIEL
STMT_ERR_RET(qBuildStmtStbColFields(*pDataBlock, pStmt->bInfo.boundTags, pStmt->bInfo.preCtbname, fieldNum, fields));
if (pStmt->bInfo.tbType == TSDB_SUPER_TABLE) {
pStmt->bInfo.needParse = true;
qDestroyStmtDataBlock(*pDataBlock);
if (taosHashRemove(pStmt->exec.pBlockHash, pStmt->bInfo.tbFName, strlen(pStmt->bInfo.tbFName)) != 0) {
tscError("get fileds %s remove exec blockHash fail", pStmt->bInfo.tbFName);
STMT_ERR_RET(TSDB_CODE_APP_ERROR);
@ -1910,7 +1911,7 @@ int stmtGetColFields2(TAOS_STMT2* stmt, int* nums, TAOS_FIELD_E** fields) {
return stmtFetchColFields2(stmt, nums, fields);
}
int stmtGetStbColFields2(TAOS_STMT2* stmt, int* nums, TAOS_FIELD_STB** fields) {
int stmtGetStbColFields2(TAOS_STMT2* stmt, int* nums, TAOS_FIELD_ALL** fields) {
int32_t code = stmtParseColFields2(stmt);
if (code != TSDB_CODE_SUCCESS) {
return code;

View File

@ -651,6 +651,7 @@ int32_t tEncodeStreamHbRsp(SEncoder* pEncoder, const SMStreamHbRspMsg* pRsp) {
TAOS_CHECK_EXIT(tStartEncode(pEncoder));
TAOS_CHECK_EXIT(tEncodeI32(pEncoder, pRsp->msgId));
TAOS_CHECK_EXIT(tEncodeSEpSet(pEncoder, &pRsp->mndEpset));
tEndEncode(pEncoder);
_exit:
@ -663,6 +664,7 @@ int32_t tDecodeStreamHbRsp(SDecoder* pDecoder, SMStreamHbRspMsg* pRsp) {
TAOS_CHECK_EXIT(tStartDecode(pDecoder));
TAOS_CHECK_EXIT(tDecodeI32(pDecoder, &pRsp->msgId));
TAOS_CHECK_EXIT(tDecodeSEpSet(pDecoder, &pRsp->mndEpset));
tEndDecode(pDecoder);
_exit:

Some files were not shown because too many files have changed in this diff Show More