提交 a18677ac 编写于 作者: C Cary Xu

Merge branch '3.0' into feature/TD-14481-3.0

```c
{{#include docs-examples/c/line_example.c:main}}
```
\ No newline at end of file
```c
{{#include docs-examples/c/json_protocol_example.c:main}}
```
\ No newline at end of file
```c
{{#include docs-examples/c/telnet_line_example.c:main}}
```
\ No newline at end of file
```c
{{#include docs-examples/c/insert_example.c}}
```
\ No newline at end of file
```csharp
{{#include docs-examples/csharp/InfluxDBLineExample.cs}}
```
```csharp
{{#include docs-examples/csharp/OptsJsonExample.cs}}
```
```csharp
{{#include docs-examples/csharp/OptsTelnetExample.cs}}
```
```csharp
{{#include docs-examples/csharp/SQLInsertExample.cs}}
```
```csharp
{{#include docs-examples/csharp/StmtInsertExample.cs}}
```
```go
{{#include docs-examples/go/insert/line/main.go}}
```
```go
{{#include docs-examples/go/insert/json/main.go}}
```
```go
{{#include docs-examples/go/insert/telnet/main.go}}
```
```go
{{#include docs-examples/go/insert/sql/main.go}}
```
```js
{{#include docs-examples/node/nativeexample/influxdb_line_example.js}}
```
```js
{{#include docs-examples/node/nativeexample/opentsdb_json_example.js}}
```
```js
{{#include docs-examples/node/nativeexample/opentsdb_telnet_example.js}}
```
```js
{{#include docs-examples/node/nativeexample/insert_example.js}}
```
```php
{{#include docs-examples/php/insert.php}}
```
```php
{{#include docs-examples/php/insert_stmt.php}}
```
```py
{{#include docs-examples/python/line_protocol_example.py}}
```
```py
{{#include docs-examples/python/json_protocol_example.py}}
```
```py
{{#include docs-examples/python/telnet_line_protocol_example.py}}
```
```py
{{#include docs-examples/python/native_insert_example.py}}
```
```rust
{{#include docs-examples/rust/restexample/examples/insert_example.rs}}
```
```rust
{{#include docs-examples/rust/nativeexample/examples/stmt_example.rs}}
```
```c
{{#include docs-examples/c/query_example.c}}
```
\ No newline at end of file
```c
{{#include docs-examples/c/async_query_example.c:demo}}
```
\ No newline at end of file
```csharp
{{#include docs-examples/csharp/QueryExample.cs}}
```
```csharp
{{#include docs-examples/csharp/AsyncQueryExample.cs}}
```
```go
{{#include docs-examples/go/query/sync/main.go}}
```
```go
{{#include docs-examples/go/query/async/main.go}}
```
```js
{{#include docs-examples/node/nativeexample/query_example.js}}
```
```js
{{#include docs-examples/node/nativeexample/async_query_example.js}}
```
```go
{{#include docs-examples/php/query.php}}
```
```rust
{{#include docs-examples/rust/restexample/examples/query_example.rs}}
```
```c
{{#include docs-examples/c/subscribe_demo.c}}
```
\ No newline at end of file
```csharp
{{#include docs-examples/csharp/SubscribeDemo.cs}}
```
\ No newline at end of file
```go
{{#include docs-examples/go/sub/main.go}}
```
\ No newline at end of file
```js
{{#include docs-examples/node/nativeexample/subscribe_demo.js}}
```
\ No newline at end of file
```py
{{#include docs-examples/python/subscribe_demo.py}}
```
\ No newline at end of file
```rs
{{#include docs-examples/rust/nativeexample/examples/subscribe_demo.rs}}
```
\ No newline at end of file
```c
{{#include docs-examples/c/line_example.c:main}}
```
\ No newline at end of file
```c
{{#include docs-examples/c/json_protocol_example.c:main}}
```
\ No newline at end of file
```c
{{#include docs-examples/c/telnet_line_example.c:main}}
```
\ No newline at end of file
```c
{{#include docs-examples/c/insert_example.c}}
```
\ No newline at end of file
```csharp
{{#include docs-examples/csharp/InfluxDBLineExample.cs}}
```
```csharp
{{#include docs-examples/csharp/OptsJsonExample.cs}}
```
```csharp
{{#include docs-examples/csharp/OptsTelnetExample.cs}}
```
```csharp
{{#include docs-examples/csharp/SQLInsertExample.cs}}
```
```csharp
{{#include docs-examples/csharp/StmtInsertExample.cs}}
```
```go
{{#include docs-examples/go/insert/line/main.go}}
```
```go
{{#include docs-examples/go/insert/json/main.go}}
```
```go
{{#include docs-examples/go/insert/telnet/main.go}}
```
```go
{{#include docs-examples/go/insert/sql/main.go}}
```
```js
{{#include docs-examples/node/nativeexample/influxdb_line_example.js}}
```
```js
{{#include docs-examples/node/nativeexample/opentsdb_json_example.js}}
```
```js
{{#include docs-examples/node/nativeexample/opentsdb_telnet_example.js}}
```
```js
{{#include docs-examples/node/nativeexample/insert_example.js}}
```
```py
{{#include docs-examples/python/line_protocol_example.py}}
```
```py
{{#include docs-examples/python/json_protocol_example.py}}
```
```py
{{#include docs-examples/python/telnet_line_protocol_example.py}}
```
```py
{{#include docs-examples/python/native_insert_example.py}}
```
```rust
{{#include docs-examples/rust/restexample/examples/insert_example.rs}}
```
```rust
{{#include docs-examples/rust/nativeexample/examples/stmt_example.rs}}
```
```c
{{#include docs-examples/c/query_example.c}}
```
\ No newline at end of file
```c
{{#include docs-examples/c/async_query_example.c:demo}}
```
\ No newline at end of file
```csharp
{{#include docs-examples/csharp/QueryExample.cs}}
```
```csharp
{{#include docs-examples/csharp/AsyncQueryExample.cs}}
```
```go
{{#include docs-examples/go/query/sync/main.go}}
```
```go
{{#include docs-examples/go/query/async/main.go}}
```
```js
{{#include docs-examples/node/nativeexample/query_example.js}}
```
```js
{{#include docs-examples/node/nativeexample/async_query_example.js}}
```
```rust
{{#include docs-examples/rust/restexample/examples/query_example.rs}}
```
```c
{{#include docs-examples/c/subscribe_demo.c}}
```
\ No newline at end of file
```csharp
{{#include docs-examples/csharp/SubscribeDemo.cs}}
```
\ No newline at end of file
```go
{{#include docs-examples/go/sub/main.go}}
```
\ No newline at end of file
```js
{{#include docs-examples/node/nativeexample/subscribe_demo.js}}
```
\ No newline at end of file
```py
{{#include docs-examples/python/subscribe_demo.py}}
```
\ No newline at end of file
```rs
{{#include docs-examples/rust/nativeexample/examples/subscribe_demo.rs}}
```
\ No newline at end of file
package main
import (
"database/sql"
"fmt"
_ "github.com/taosdata/driver-go/v2/taosRestful"
)
func createStable(taos *sql.DB) {
_, err := taos.Exec("CREATE DATABASE power")
if err != nil {
fmt.Println("failed to create database, err:", err)
}
_, err = taos.Exec("CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (location BINARY(64), groupId INT)")
if err != nil {
fmt.Println("failed to create stable, err:", err)
}
}
func insertData(taos *sql.DB) {
sql := `INSERT INTO power.d1001 USING power.meters TAGS(California.SanFrancisco, 2) VALUES ('2018-10-03 14:38:05.000', 10.30000, 219, 0.31000) ('2018-10-03 14:38:15.000', 12.60000, 218, 0.33000) ('2018-10-03 14:38:16.800', 12.30000, 221, 0.31000)
power.d1002 USING power.meters TAGS(California.SanFrancisco, 3) VALUES ('2018-10-03 14:38:16.650', 10.30000, 218, 0.25000)
power.d1003 USING power.meters TAGS(California.LosAngeles, 2) VALUES ('2018-10-03 14:38:05.500', 11.80000, 221, 0.28000) ('2018-10-03 14:38:16.600', 13.40000, 223, 0.29000)
power.d1004 USING power.meters TAGS(California.LosAngeles, 3) VALUES ('2018-10-03 14:38:05.000', 10.80000, 223, 0.29000) ('2018-10-03 14:38:06.500', 11.50000, 221, 0.35000)`
result, err := taos.Exec(sql)
if err != nil {
fmt.Println("failed to insert, err:", err)
return
}
rowsAffected, err := result.RowsAffected()
if err != nil {
fmt.Println("failed to get affected rows, err:", err)
return
}
fmt.Println("RowsAffected", rowsAffected)
}
func main() {
var taosDSN = "root:taosdata@http(localhost:6041)/"
taos, err := sql.Open("taosRestful", taosDSN)
if err != nil {
fmt.Println("failed to connect TDengine, err:", err)
return
}
defer taos.Close()
createStable(taos)
insertData(taos)
}
```c title="Native Connection" ```c title="Native Connection"
{{#include docs-examples/c/connect_example.c}} {{#include docs/examples/c/connect_example.c}}
``` ```
```csharp title="Native Connection" ```csharp title="Native Connection"
{{#include docs-examples/csharp/ConnectExample.cs}} {{#include docs/examples/csharp/ConnectExample.cs}}
``` ```
:::info :::info
......
#### Unified Database Access Interface #### Unified Database Access Interface
```go title="Native Connection" ```go title="Native Connection"
{{#include docs-examples/go/connect/cgoexample/main.go}} {{#include docs/examples/go/connect/cgoexample/main.go}}
``` ```
```go title="REST Connection" ```go title="REST Connection"
{{#include docs-examples/go/connect/restexample/main.go}} {{#include docs/examples/go/connect/restexample/main.go}}
``` ```
#### Advanced Features #### Advanced Features
...@@ -13,5 +13,5 @@ ...@@ -13,5 +13,5 @@
The af package of driver-go can also be used to establish connection, with this way some advanced features of TDengine, like parameter binding and subscription, can be used. The af package of driver-go can also be used to establish connection, with this way some advanced features of TDengine, like parameter binding and subscription, can be used.
```go title="Establish native connection using af package" ```go title="Establish native connection using af package"
{{#include docs-examples/go/connect/afconn/main.go}} {{#include docs/examples/go/connect/afconn/main.go}}
``` ```
```java title="Native Connection" ```java title="Native Connection"
{{#include docs-examples/java/src/main/java/com/taos/example/JNIConnectExample.java}} {{#include docs/examples/java/src/main/java/com/taos/example/JNIConnectExample.java}}
``` ```
```java title="REST Connection" ```java title="REST Connection"
{{#include docs-examples/java/src/main/java/com/taos/example/RESTConnectExample.java:main}} {{#include docs/examples/java/src/main/java/com/taos/example/RESTConnectExample.java:main}}
``` ```
When using REST connection, the feature of bulk pulling can be enabled if the size of resulting data set is huge. When using REST connection, the feature of bulk pulling can be enabled if the size of resulting data set is huge.
```java title="Enable Bulk Pulling" {4} ```java title="Enable Bulk Pulling" {4}
{{#include docs-examples/java/src/main/java/com/taos/example/WSConnectExample.java:main}} {{#include docs/examples/java/src/main/java/com/taos/example/WSConnectExample.java:main}}
``` ```
More configuration about connection,please refer to [Java Connector](/reference/connector/java) More configuration about connection,please refer to [Java Connector](/reference/connector/java)
```js title="Native Connection" ```js title="Native Connection"
{{#include docs-examples/node/nativeexample/connect.js}} {{#include docs/examples/node/nativeexample/connect.js}}
``` ```
```js title="REST Connection" ```js title="REST Connection"
{{#include docs-examples/node/restexample/connect.js}} {{#include docs/examples/node/restexample/connect.js}}
``` ```
```python title="Native Connection" ```python title="Native Connection"
{{#include docs-examples/python/connect_example.py}} {{#include docs/examples/python/connect_example.py}}
``` ```
```r title="Native Connection" ```r title="Native Connection"
{{#include docs-examples/R/connect_native.r:demo}} {{#include docs/examples/R/connect_native.r:demo}}
``` ```
```rust title="Native Connection/REST Connection" ```rust title="Native Connection/REST Connection"
{{#include docs-examples/rust/nativeexample/examples/connect.rs}} {{#include docs/examples/rust/nativeexample/examples/connect.rs}}
``` ```
:::note :::note
......
```c
{{#include docs/examples/c/line_example.c:main}}
```
\ No newline at end of file
```c
{{#include docs/examples/c/json_protocol_example.c:main}}
```
\ No newline at end of file
```c
{{#include docs/examples/c/telnet_line_example.c:main}}
```
\ No newline at end of file
```c
{{#include docs/examples/c/insert_example.c}}
```
\ No newline at end of file
```c title=Single Row Binding ```c title=Single Row Binding
{{#include docs-examples/c/stmt_example.c}} {{#include docs/examples/c/stmt_example.c}}
``` ```
```c title=Multiple Row Binding 72:117 ```c title=Multiple Row Binding 72:117
{{#include docs-examples/c/multi_bind_example.c}} {{#include docs/examples/c/multi_bind_example.c}}
``` ```
\ No newline at end of file
```csharp
{{#include docs/examples/csharp/InfluxDBLineExample.cs}}
```
```csharp
{{#include docs/examples/csharp/OptsJsonExample.cs}}
```
```csharp
{{#include docs/examples/csharp/OptsTelnetExample.cs}}
```
```csharp
{{#include docs/examples/csharp/SQLInsertExample.cs}}
```
```csharp
{{#include docs/examples/csharp/StmtInsertExample.cs}}
```
```go
{{#include docs/examples/go/insert/line/main.go}}
```
```go
{{#include docs/examples/go/insert/json/main.go}}
```
```go
{{#include docs/examples/go/insert/telnet/main.go}}
```
```go
{{#include docs/examples/go/insert/sql/main.go}}
```
```go ```go
{{#include docs-examples/go/insert/stmt/main.go}} {{#include docs/examples/go/insert/stmt/main.go}}
``` ```
:::tip :::tip
......
```java ```java
{{#include docs-examples/java/src/main/java/com/taos/example/LineProtocolExample.java}} {{#include docs/examples/java/src/main/java/com/taos/example/LineProtocolExample.java}}
``` ```
```java ```java
{{#include docs-examples/java/src/main/java/com/taos/example/JSONProtocolExample.java}} {{#include docs/examples/java/src/main/java/com/taos/example/JSONProtocolExample.java}}
``` ```
```java ```java
{{#include docs-examples/java/src/main/java/com/taos/example/TelnetLineProtocolExample.java}} {{#include docs/examples/java/src/main/java/com/taos/example/TelnetLineProtocolExample.java}}
``` ```
```java ```java
{{#include docs-examples/java/src/main/java/com/taos/example/RestInsertExample.java:insert}} {{#include docs/examples/java/src/main/java/com/taos/example/RestInsertExample.java:insert}}
``` ```
\ No newline at end of file
```java ```java
{{#include docs-examples/java/src/main/java/com/taos/example/StmtInsertExample.java}} {{#include docs/examples/java/src/main/java/com/taos/example/StmtInsertExample.java}}
``` ```
```js
{{#include docs/examples/node/nativeexample/influxdb_line_example.js}}
```
```js
{{#include docs/examples/node/nativeexample/opentsdb_json_example.js}}
```
```js
{{#include docs/examples/node/nativeexample/opentsdb_telnet_example.js}}
```
```js
{{#include docs/examples/node/nativeexample/insert_example.js}}
```
```js title=Single Row Binding ```js title=Single Row Binding
{{#include docs-examples/node/nativeexample/param_bind_example.js}} {{#include docs/examples/node/nativeexample/param_bind_example.js}}
``` ```
```js title=Multiple Row Binding ```js title=Multiple Row Binding
{{#include docs-examples/node/nativeexample/multi_bind_example.js:insertData}} {{#include docs/examples/node/nativeexample/multi_bind_example.js:insertData}}
``` ```
:::info :::info
......
```py
{{#include docs/examples/python/line_protocol_example.py}}
```
```py
{{#include docs/examples/python/json_protocol_example.py}}
```
```py
{{#include docs/examples/python/telnet_line_protocol_example.py}}
```
```py
{{#include docs/examples/python/native_insert_example.py}}
```
```py title=Single Row Binding ```py title=Single Row Binding
{{#include docs-examples/python/bind_param_example.py}} {{#include docs/examples/python/bind_param_example.py}}
``` ```
```py title=Multiple Row Binding ```py title=Multiple Row Binding
{{#include docs-examples/python/multi_bind_example.py:bind_batch}} {{#include docs/examples/python/multi_bind_example.py:bind_batch}}
``` ```
:::info :::info
......
```rust ```rust
{{#include docs-examples/rust/schemalessexample/examples/influxdb_line_example.rs}} {{#include docs/examples/rust/schemalessexample/examples/influxdb_line_example.rs}}
``` ```
```rust ```rust
{{#include docs-examples/rust/schemalessexample/examples/opentsdb_json_example.rs}} {{#include docs/examples/rust/schemalessexample/examples/opentsdb_json_example.rs}}
``` ```
```rust ```rust
{{#include docs-examples/rust/schemalessexample/examples/opentsdb_telnet_example.rs}} {{#include docs/examples/rust/schemalessexample/examples/opentsdb_telnet_example.rs}}
``` ```
```rust
{{#include docs/examples/rust/restexample/examples/insert_example.rs}}
```
```rust
{{#include docs/examples/rust/nativeexample/examples/stmt_example.rs}}
```
```c
{{#include docs/examples/c/query_example.c}}
```
\ No newline at end of file
```c
{{#include docs/examples/c/async_query_example.c:demo}}
```
\ No newline at end of file
```csharp
{{#include docs/examples/csharp/QueryExample.cs}}
```
```csharp
{{#include docs/examples/csharp/AsyncQueryExample.cs}}
```
```go
{{#include docs/examples/go/query/sync/main.go}}
```
```go
{{#include docs/examples/go/query/async/main.go}}
```
```java ```java
{{#include docs-examples/java/src/main/java/com/taos/example/RestQueryExample.java}} {{#include docs/examples/java/src/main/java/com/taos/example/RestQueryExample.java}}
``` ```
```js
{{#include docs/examples/node/nativeexample/query_example.js}}
```
```js
{{#include docs/examples/node/nativeexample/async_query_example.js}}
```
Result set is iterated row by row. Result set is iterated row by row.
```py ```py
{{#include docs-examples/python/query_example.py:iter}} {{#include docs/examples/python/query_example.py:iter}}
``` ```
Result set is retrieved as a whole, each row is converted to a dict and returned. Result set is retrieved as a whole, each row is converted to a dict and returned.
```py ```py
{{#include docs-examples/python/query_example.py:fetch_all}} {{#include docs/examples/python/query_example.py:fetch_all}}
``` ```
\ No newline at end of file
```py ```py
{{#include docs-examples/python/async_query_example.py}} {{#include docs/examples/python/async_query_example.py}}
``` ```
:::note :::note
......
```rust
{{#include docs/examples/rust/restexample/examples/query_example.rs}}
```
```c
{{#include docs/examples/c/subscribe_demo.c}}
```
\ No newline at end of file
```csharp
{{#include docs/examples/csharp/SubscribeDemo.cs}}
```
\ No newline at end of file
```go
{{#include docs/examples/go/sub/main.go}}
```
\ No newline at end of file
```java ```java
{{#include docs-examples/java/src/main/java/com/taos/example/SubscribeDemo.java}} {{#include docs/examples/java/src/main/java/com/taos/example/SubscribeDemo.java}}
``` ```
:::note :::note
For now Java connector doesn't provide asynchronous subscription, but `TimerTask` can be used to achieve similar purpose. For now Java connector doesn't provide asynchronous subscription, but `TimerTask` can be used to achieve similar purpose.
......
```js
{{#include docs/examples/node/nativeexample/subscribe_demo.js}}
```
\ No newline at end of file
```py
{{#include docs/examples/python/subscribe_demo.py}}
```
\ No newline at end of file
```rs
{{#include docs/examples/rust/nativeexample/examples/subscribe_demo.rs}}
```
\ No newline at end of file
...@@ -91,7 +91,7 @@ In this section a few sample programs which use TDengine PHP connector to access ...@@ -91,7 +91,7 @@ In this section a few sample programs which use TDengine PHP connector to access
<summary>Establish Connection</summary> <summary>Establish Connection</summary>
```c ```c
{{#include docs-examples/php/connect.php}} {{#include docs/examples/php/connect.php}}
``` ```
</details> </details>
...@@ -102,7 +102,7 @@ In this section a few sample programs which use TDengine PHP connector to access ...@@ -102,7 +102,7 @@ In this section a few sample programs which use TDengine PHP connector to access
<summary>Insert Data</summary> <summary>Insert Data</summary>
```c ```c
{{#include docs-examples/php/insert.php}} {{#include docs/examples/php/insert.php}}
``` ```
</details> </details>
...@@ -113,7 +113,7 @@ In this section a few sample programs which use TDengine PHP connector to access ...@@ -113,7 +113,7 @@ In this section a few sample programs which use TDengine PHP connector to access
<summary>Synchronous Query</summary> <summary>Synchronous Query</summary>
```c ```c
{{#include docs-examples/php/query.php}} {{#include docs/examples/php/query.php}}
``` ```
</details> </details>
...@@ -124,7 +124,7 @@ In this section a few sample programs which use TDengine PHP connector to access ...@@ -124,7 +124,7 @@ In this section a few sample programs which use TDengine PHP connector to access
<summary>Parameter Binding</summary> <summary>Parameter Binding</summary>
```c ```c
{{#include docs-examples/php/insert_stmt.php}} {{#include docs/examples/php/insert_stmt.php}}
``` ```
</details> </details>
......
...@@ -169,7 +169,7 @@ The following example code assumes that TDengine is installed locally and that t ...@@ -169,7 +169,7 @@ The following example code assumes that TDengine is installed locally and that t
<TabItem value="native" label="native connection" groupId="connect"> <TabItem value="native" label="native connection" groupId="connect">
```python ```python
{{#include docs-examples/python/connect_native_reference.py}} {{#include docs/examples/python/connect_native_reference.py}}
``` ```
All arguments of the `connect()` function are optional keyword arguments. The following are the connection parameters specified. All arguments of the `connect()` function are optional keyword arguments. The following are the connection parameters specified.
...@@ -194,7 +194,7 @@ The `connect()` function returns a `taos.TaosConnection` instance. In client-sid ...@@ -194,7 +194,7 @@ The `connect()` function returns a `taos.TaosConnection` instance. In client-sid
<TabItem value="rest" label="REST connection"> <TabItem value="rest" label="REST connection">
```python ```python
{{#include docs-examples/python/connect_rest_examples.py:connect}} {{#include docs/examples/python/connect_rest_examples.py:connect}}
``` ```
All arguments to the `connect()` function are optional keyword arguments. The following are the connection parameters specified. All arguments to the `connect()` function are optional keyword arguments. The following are the connection parameters specified.
...@@ -219,11 +219,11 @@ All arguments to the `connect()` function are optional keyword arguments. The fo ...@@ -219,11 +219,11 @@ All arguments to the `connect()` function are optional keyword arguments. The fo
The `TaosConnection` class contains both an implementation of the PEP249 Connection interface (e.g., the `cursor()` method and the `close()` method) and many extensions (e.g., the `execute()`, `query()`, `schemaless_insert()`, and `subscribe()` methods). The `TaosConnection` class contains both an implementation of the PEP249 Connection interface (e.g., the `cursor()` method and the `close()` method) and many extensions (e.g., the `execute()`, `query()`, `schemaless_insert()`, and `subscribe()` methods).
```python title="execute method" ```python title="execute method"
{{#include docs-examples/python/connection_usage_native_reference.py:insert}} {{#include docs/examples/python/connection_usage_native_reference.py:insert}}
``` ```
```python title="query method" ```python title="query method"
{{#include docs-examples/python/connection_usage_native_reference.py:query}} {{#include docs/examples/python/connection_usage_native_reference.py:query}}
``` ```
:::tip :::tip
...@@ -235,14 +235,14 @@ The queried results can only be fetched once. For example, only one of `fetch_al ...@@ -235,14 +235,14 @@ The queried results can only be fetched once. For example, only one of `fetch_al
In the above example of using the `TaosConnection` class, we have shown two ways to get the result of a query: `fetch_all()` and `fetch_all_into_dict()`. In addition, `TaosResult` also provides methods to iterate through the result set by rows (`rows_iter`) or by data blocks (`blocks_iter`). Using these two methods will be more efficient in scenarios where the query has a large amount of data. In the above example of using the `TaosConnection` class, we have shown two ways to get the result of a query: `fetch_all()` and `fetch_all_into_dict()`. In addition, `TaosResult` also provides methods to iterate through the result set by rows (`rows_iter`) or by data blocks (`blocks_iter`). Using these two methods will be more efficient in scenarios where the query has a large amount of data.
```python title="blocks_iter method" ```python title="blocks_iter method"
{{#include docs-examples/python/result_set_examples.py}} {{#include docs/examples/python/result_set_examples.py}}
``` ```
##### Use of the TaosCursor class ##### Use of the TaosCursor class
The `TaosConnection` class and the `TaosResult` class already implement all the functionality of the native interface. If you are familiar with the interfaces in the PEP249 specification, you can also use the methods provided by the `TaosCursor` class. The `TaosConnection` class and the `TaosResult` class already implement all the functionality of the native interface. If you are familiar with the interfaces in the PEP249 specification, you can also use the methods provided by the `TaosCursor` class.
```python title="Use of TaosCursor" ```python title="Use of TaosCursor"
{{#include docs-examples/python/cursor_usage_native_reference.py}} {{#include docs/examples/python/cursor_usage_native_reference.py}}
``` ```
:::note :::note
...@@ -258,7 +258,7 @@ The TaosCursor class uses native connections for write and query operations. In ...@@ -258,7 +258,7 @@ The TaosCursor class uses native connections for write and query operations. In
The ``TaosRestCursor`` class is an implementation of the PEP249 Cursor interface. The ``TaosRestCursor`` class is an implementation of the PEP249 Cursor interface.
```python title="Use of TaosRestCursor" ```python title="Use of TaosRestCursor"
{{#include docs-examples/python/connect_rest_examples.py:basic}} {{#include docs/examples/python/connect_rest_examples.py:basic}}
``` ```
- `cursor.execute` : Used to execute arbitrary SQL statements. - `cursor.execute` : Used to execute arbitrary SQL statements.
- `cursor.rowcount` : For write operations, returns the number of successful rows written. For query operations, returns the number of rows in the result set. - `cursor.rowcount` : For write operations, returns the number of successful rows written. For query operations, returns the number of rows in the result set.
...@@ -269,7 +269,7 @@ The ``TaosRestCursor`` class is an implementation of the PEP249 Cursor interface ...@@ -269,7 +269,7 @@ The ``TaosRestCursor`` class is an implementation of the PEP249 Cursor interface
The `RestClient` class is a direct wrapper for the [REST API](/reference/rest-api). It contains only a `sql()` method for executing arbitrary SQL statements and returning the result. The `RestClient` class is a direct wrapper for the [REST API](/reference/rest-api). It contains only a `sql()` method for executing arbitrary SQL statements and returning the result.
```python title="Use of RestClient" ```python title="Use of RestClient"
{{#include docs-examples/python/rest_client_example.py}} {{#include docs/examples/python/rest_client_example.py}}
``` ```
For a more detailed description of the `sql()` method, please refer to [RestClient](https://docs.taosdata.com/api/taospy/taosrest/restclient.html). For a more detailed description of the `sql()` method, please refer to [RestClient](https://docs.taosdata.com/api/taospy/taosrest/restclient.html).
...@@ -283,14 +283,14 @@ For a more detailed description of the `sql()` method, please refer to [RestClie ...@@ -283,14 +283,14 @@ For a more detailed description of the `sql()` method, please refer to [RestClie
<TabItem value="native" label="native connection"> <TabItem value="native" label="native connection">
```python ```python
{{#include docs-examples/python/conn_native_pandas.py}} {{#include docs/examples/python/conn_native_pandas.py}}
``` ```
</TabItem> </TabItem>
<TabItem value="rest" label="REST connection"> <TabItem value="rest" label="REST connection">
```python ```python
{{#include docs-examples/python/conn_rest_pandas.py}} {{#include docs/examples/python/conn_rest_pandas.py}}
``` ```
</TabItem> </TabItem>
...@@ -314,7 +314,7 @@ For a more detailed description of the `sql()` method, please refer to [RestClie ...@@ -314,7 +314,7 @@ For a more detailed description of the `sql()` method, please refer to [RestClie
All errors from database operations are thrown directly as exceptions and the error message from the database is passed up the exception stack. The application is responsible for exception handling. For example: All errors from database operations are thrown directly as exceptions and the error message from the database is passed up the exception stack. The application is responsible for exception handling. For example:
```python ```python
{{#include docs-examples/python/handle_exception.py}} {{#include docs/examples/python/handle_exception.py}}
``` ```
### About nanoseconds ### About nanoseconds
......
...@@ -108,7 +108,7 @@ Finally, click the "Create" button at bottom left corner saving the rule. ...@@ -108,7 +108,7 @@ Finally, click the "Create" button at bottom left corner saving the rule.
## Compose program to mock data ## Compose program to mock data
```javascript ```javascript
{{#include docs-examples/other/mock.js}} {{#include docs/examples/other/mock.js}}
``` ```
Note: `CLIENT_NUM` in the code can be set to a smaller value at the beginning of the test to avoid hardware performance be not capable to handle a more significant number of concurrent clients. Note: `CLIENT_NUM` in the code can be set to a smaller value at the beginning of the test to avoid hardware performance be not capable to handle a more significant number of concurrent clients.
......
```c title="原生连接" ```c title="原生连接"
{{#include docs-examples/c/connect_example.c}} {{#include docs/examples/c/connect_example.c}}
``` ```
```csharp title="原生连接" ```csharp title="原生连接"
{{#include docs-examples/csharp/ConnectExample.cs}} {{#include docs/examples/csharp/ConnectExample.cs}}
``` ```
:::info :::info
......
#### 使用数据库访问统一接口 #### 使用数据库访问统一接口
```go title="原生连接" ```go title="原生连接"
{{#include docs-examples/go/connect/cgoexample/main.go}} {{#include docs/examples/go/connect/cgoexample/main.go}}
``` ```
```go title="REST 连接" ```go title="REST 连接"
{{#include docs-examples/go/connect/restexample/main.go}} {{#include docs/examples/go/connect/restexample/main.go}}
``` ```
#### 使用高级封装 #### 使用高级封装
...@@ -13,5 +13,5 @@ ...@@ -13,5 +13,5 @@
也可以使用 driver-go 的 af 包建立连接。这个模块封装了 TDengine 的高级功能, 如:参数绑定、订阅等。 也可以使用 driver-go 的 af 包建立连接。这个模块封装了 TDengine 的高级功能, 如:参数绑定、订阅等。
```go title="使用 af 包建立原生连接" ```go title="使用 af 包建立原生连接"
{{#include docs-examples/go/connect/afconn/main.go}} {{#include docs/examples/go/connect/afconn/main.go}}
``` ```
```java title="原生连接" ```java title="原生连接"
{{#include docs-examples/java/src/main/java/com/taos/example/JNIConnectExample.java}} {{#include docs/examples/java/src/main/java/com/taos/example/JNIConnectExample.java}}
``` ```
```java title="REST 连接" ```java title="REST 连接"
{{#include docs-examples/java/src/main/java/com/taos/example/RESTConnectExample.java:main}} {{#include docs/examples/java/src/main/java/com/taos/example/RESTConnectExample.java:main}}
``` ```
使用 REST 连接时,如果查询数据量比较大,还可开启批量拉取功能。 使用 REST 连接时,如果查询数据量比较大,还可开启批量拉取功能。
```java title="开启批量拉取功能" {4} ```java title="开启批量拉取功能" {4}
{{#include docs-examples/java/src/main/java/com/taos/example/WSConnectExample.java:main}} {{#include docs/examples/java/src/main/java/com/taos/example/WSConnectExample.java:main}}
``` ```
更多连接参数配置,参考[Java 连接器](/reference/connector/java) 更多连接参数配置,参考[Java 连接器](/reference/connector/java)
```js title="原生连接" ```js title="原生连接"
{{#include docs-examples/node/nativeexample/connect.js}} {{#include docs/examples/node/nativeexample/connect.js}}
``` ```
```js title="REST 连接" ```js title="REST 连接"
{{#include docs-examples/node/restexample/connect.js}} {{#include docs/examples/node/restexample/connect.js}}
``` ```
```php title="原生连接" ```php title="原生连接"
{{#include docs-examples/php/connect.php}} {{#include docs/examples/php/connect.php}}
``` ```
```python title="原生连接" ```python title="原生连接"
{{#include docs-examples/python/connect_example.py}} {{#include docs/examples/python/connect_example.py}}
``` ```
```r title="原生连接" ```r title="原生连接"
{{#include docs-examples/R/connect_native.r:demo}} {{#include docs/examples/R/connect_native.r:demo}}
``` ```
```rust title="原生连接/REST 连接" ```rust title="原生连接/REST 连接"
{{#include docs-examples/rust/nativeexample/examples/connect.rs}} {{#include docs/examples/rust/nativeexample/examples/connect.rs}}
``` ```
:::note :::note
......
```c
{{#include docs/examples/c/line_example.c:main}}
```
\ No newline at end of file
```c
{{#include docs/examples/c/json_protocol_example.c:main}}
```
\ No newline at end of file
```c
{{#include docs/examples/c/telnet_line_example.c:main}}
```
\ No newline at end of file
```c
{{#include docs/examples/c/insert_example.c}}
```
\ No newline at end of file
```c title=一次绑定一行 ```c title=一次绑定一行
{{#include docs-examples/c/stmt_example.c}} {{#include docs/examples/c/stmt_example.c}}
``` ```
```c title=一次绑定多行 72:117 ```c title=一次绑定多行 72:117
{{#include docs-examples/c/multi_bind_example.c}} {{#include docs/examples/c/multi_bind_example.c}}
``` ```
\ No newline at end of file
```csharp
{{#include docs/examples/csharp/InfluxDBLineExample.cs}}
```
```csharp
{{#include docs/examples/csharp/OptsJsonExample.cs}}
```
```csharp
{{#include docs/examples/csharp/OptsTelnetExample.cs}}
```
```csharp
{{#include docs/examples/csharp/SQLInsertExample.cs}}
```
```csharp
{{#include docs/examples/csharp/StmtInsertExample.cs}}
```
```go
{{#include docs/examples/go/insert/line/main.go}}
```
```go
{{#include docs/examples/go/insert/json/main.go}}
```
```go
{{#include docs/examples/go/insert/telnet/main.go}}
```
```go
{{#include docs/examples/go/insert/sql/main.go}}
```
```go ```go
{{#include docs-examples/go/insert/stmt/main.go}} {{#include docs/examples/go/insert/stmt/main.go}}
``` ```
:::tip :::tip
......
```java ```java
{{#include docs-examples/java/src/main/java/com/taos/example/LineProtocolExample.java}} {{#include docs/examples/java/src/main/java/com/taos/example/LineProtocolExample.java}}
``` ```
```java ```java
{{#include docs-examples/java/src/main/java/com/taos/example/JSONProtocolExample.java}} {{#include docs/examples/java/src/main/java/com/taos/example/JSONProtocolExample.java}}
``` ```
```java ```java
{{#include docs-examples/java/src/main/java/com/taos/example/TelnetLineProtocolExample.java}} {{#include docs/examples/java/src/main/java/com/taos/example/TelnetLineProtocolExample.java}}
``` ```
```java ```java
{{#include docs-examples/java/src/main/java/com/taos/example/RestInsertExample.java:insert}} {{#include docs/examples/java/src/main/java/com/taos/example/RestInsertExample.java:insert}}
``` ```
\ No newline at end of file
```java ```java
{{#include docs-examples/java/src/main/java/com/taos/example/StmtInsertExample.java}} {{#include docs/examples/java/src/main/java/com/taos/example/StmtInsertExample.java}}
``` ```
```js
{{#include docs/examples/node/nativeexample/influxdb_line_example.js}}
```
```js
{{#include docs/examples/node/nativeexample/opentsdb_json_example.js}}
```
```js
{{#include docs/examples/node/nativeexample/opentsdb_telnet_example.js}}
```
```js
{{#include docs/examples/node/nativeexample/insert_example.js}}
```
```js title=一次绑定一行 ```js title=一次绑定一行
{{#include docs-examples/node/nativeexample/param_bind_example.js}} {{#include docs/examples/node/nativeexample/param_bind_example.js}}
``` ```
```js title=一次绑定多行 ```js title=一次绑定多行
{{#include docs-examples/node/nativeexample/multi_bind_example.js:insertData}} {{#include docs/examples/node/nativeexample/multi_bind_example.js:insertData}}
``` ```
:::info :::info
......
```php
{{#include docs/examples/php/insert.php}}
```
```php
{{#include docs/examples/php/insert_stmt.php}}
```
```py
{{#include docs/examples/python/line_protocol_example.py}}
```
```py
{{#include docs/examples/python/json_protocol_example.py}}
```
```py
{{#include docs/examples/python/telnet_line_protocol_example.py}}
```
```py
{{#include docs/examples/python/native_insert_example.py}}
```
```py title=一次绑定一行 ```py title=一次绑定一行
{{#include docs-examples/python/bind_param_example.py}} {{#include docs/examples/python/bind_param_example.py}}
``` ```
```py title=一次绑定多行 ```py title=一次绑定多行
{{#include docs-examples/python/multi_bind_example.py:bind_batch}} {{#include docs/examples/python/multi_bind_example.py:bind_batch}}
``` ```
:::info :::info
......
```rust ```rust
{{#include docs-examples/rust/schemalessexample/examples/influxdb_line_example.rs}} {{#include docs/examples/rust/schemalessexample/examples/influxdb_line_example.rs}}
``` ```
```rust ```rust
{{#include docs-examples/rust/schemalessexample/examples/opentsdb_json_example.rs}} {{#include docs/examples/rust/schemalessexample/examples/opentsdb_json_example.rs}}
``` ```
```rust ```rust
{{#include docs-examples/rust/schemalessexample/examples/opentsdb_telnet_example.rs}} {{#include docs/examples/rust/schemalessexample/examples/opentsdb_telnet_example.rs}}
``` ```
```rust
{{#include docs/examples/rust/restexample/examples/insert_example.rs}}
```
```rust
{{#include docs/examples/rust/nativeexample/examples/stmt_example.rs}}
```
```c
{{#include docs/examples/c/query_example.c}}
```
\ No newline at end of file
```c
{{#include docs/examples/c/async_query_example.c:demo}}
```
\ No newline at end of file
```csharp
{{#include docs/examples/csharp/QueryExample.cs}}
```
```csharp
{{#include docs/examples/csharp/AsyncQueryExample.cs}}
```
```go
{{#include docs/examples/go/query/sync/main.go}}
```
```go
{{#include docs/examples/go/query/async/main.go}}
```
```java ```java
{{#include docs-examples/java/src/main/java/com/taos/example/RestQueryExample.java}} {{#include docs/examples/java/src/main/java/com/taos/example/RestQueryExample.java}}
``` ```
```js
{{#include docs/examples/node/nativeexample/query_example.js}}
```
```js
{{#include docs/examples/node/nativeexample/async_query_example.js}}
```
```go
{{#include docs/examples/php/query.php}}
```
通过迭代逐行获取查询结果。 通过迭代逐行获取查询结果。
```py ```py
{{#include docs-examples/python/query_example.py:iter}} {{#include docs/examples/python/query_example.py:iter}}
``` ```
一次获取所有查询结果,并把每一行转化为一个字典返回。 一次获取所有查询结果,并把每一行转化为一个字典返回。
```py ```py
{{#include docs-examples/python/query_example.py:fetch_all}} {{#include docs/examples/python/query_example.py:fetch_all}}
``` ```
```py ```py
{{#include docs-examples/python/async_query_example.py}} {{#include docs/examples/python/async_query_example.py}}
``` ```
:::note :::note
......
```rust
{{#include docs/examples/rust/restexample/examples/query_example.rs}}
```
```c
{{#include docs/examples/c/subscribe_demo.c}}
```
\ No newline at end of file
```csharp
{{#include docs/examples/csharp/SubscribeDemo.cs}}
```
\ No newline at end of file
```go
{{#include docs/examples/go/sub/main.go}}
```
\ No newline at end of file
```java ```java
{{#include docs-examples/java/src/main/java/com/taos/example/SubscribeDemo.java}} {{#include docs/examples/java/src/main/java/com/taos/example/SubscribeDemo.java}}
``` ```
:::note :::note
目前 Java 接口没有提供异步订阅模式,但用户程序可以通过创建 `TimerTask` 等方式达到同样的效果。 目前 Java 接口没有提供异步订阅模式,但用户程序可以通过创建 `TimerTask` 等方式达到同样的效果。
......
```js
{{#include docs/examples/node/nativeexample/subscribe_demo.js}}
```
\ No newline at end of file
```py
{{#include docs/examples/python/subscribe_demo.py}}
```
\ No newline at end of file
```rs
{{#include docs/examples/rust/nativeexample/examples/subscribe_demo.rs}}
```
\ No newline at end of file
...@@ -91,7 +91,7 @@ phpize && ./configure --enable-swoole && make -j && make install ...@@ -91,7 +91,7 @@ phpize && ./configure --enable-swoole && make -j && make install
<summary>建立连接</summary> <summary>建立连接</summary>
```c ```c
{{#include docs-examples/php/connect.php}} {{#include docs/examples/php/connect.php}}
``` ```
</details> </details>
...@@ -102,7 +102,7 @@ phpize && ./configure --enable-swoole && make -j && make install ...@@ -102,7 +102,7 @@ phpize && ./configure --enable-swoole && make -j && make install
<summary>插入数据</summary> <summary>插入数据</summary>
```c ```c
{{#include docs-examples/php/insert.php}} {{#include docs/examples/php/insert.php}}
``` ```
</details> </details>
...@@ -113,7 +113,7 @@ phpize && ./configure --enable-swoole && make -j && make install ...@@ -113,7 +113,7 @@ phpize && ./configure --enable-swoole && make -j && make install
<summary>同步查询</summary> <summary>同步查询</summary>
```c ```c
{{#include docs-examples/php/query.php}} {{#include docs/examples/php/query.php}}
``` ```
</details> </details>
...@@ -124,7 +124,7 @@ phpize && ./configure --enable-swoole && make -j && make install ...@@ -124,7 +124,7 @@ phpize && ./configure --enable-swoole && make -j && make install
<summary>参数绑定</summary> <summary>参数绑定</summary>
```c ```c
{{#include docs-examples/php/insert_stmt.php}} {{#include docs/examples/php/insert_stmt.php}}
``` ```
</details> </details>
......
...@@ -169,7 +169,7 @@ curl -u root:taosdata http://<FQDN>:<PORT>/rest/sql -d "select server_version()" ...@@ -169,7 +169,7 @@ curl -u root:taosdata http://<FQDN>:<PORT>/rest/sql -d "select server_version()"
<TabItem value="native" label="原生连接" groupId="connect"> <TabItem value="native" label="原生连接" groupId="connect">
```python ```python
{{#include docs-examples/python/connect_native_reference.py}} {{#include docs/examples/python/connect_native_reference.py}}
``` ```
`connect` 函数的所有参数都是可选的关键字参数。下面是连接参数的具体说明: `connect` 函数的所有参数都是可选的关键字参数。下面是连接参数的具体说明:
...@@ -194,7 +194,7 @@ curl -u root:taosdata http://<FQDN>:<PORT>/rest/sql -d "select server_version()" ...@@ -194,7 +194,7 @@ curl -u root:taosdata http://<FQDN>:<PORT>/rest/sql -d "select server_version()"
<TabItem value="rest" label="REST 连接"> <TabItem value="rest" label="REST 连接">
```python ```python
{{#include docs-examples/python/connect_rest_examples.py:connect}} {{#include docs/examples/python/connect_rest_examples.py:connect}}
``` ```
`connect()` 函数的所有参数都是可选的关键字参数。下面是连接参数的具体说明: `connect()` 函数的所有参数都是可选的关键字参数。下面是连接参数的具体说明:
...@@ -219,11 +219,11 @@ curl -u root:taosdata http://<FQDN>:<PORT>/rest/sql -d "select server_version()" ...@@ -219,11 +219,11 @@ curl -u root:taosdata http://<FQDN>:<PORT>/rest/sql -d "select server_version()"
`TaosConnection` 类既包含对 PEP249 Connection 接口的实现(如:`cursor`方法和 `close` 方法),也包含很多扩展功能(如: `execute`、 `query`、`schemaless_insert` 和 `subscribe` 方法。 `TaosConnection` 类既包含对 PEP249 Connection 接口的实现(如:`cursor`方法和 `close` 方法),也包含很多扩展功能(如: `execute`、 `query`、`schemaless_insert` 和 `subscribe` 方法。
```python title="execute 方法" ```python title="execute 方法"
{{#include docs-examples/python/connection_usage_native_reference.py:insert}} {{#include docs/examples/python/connection_usage_native_reference.py:insert}}
``` ```
```python title="query 方法" ```python title="query 方法"
{{#include docs-examples/python/connection_usage_native_reference.py:query}} {{#include docs/examples/python/connection_usage_native_reference.py:query}}
``` ```
:::tip :::tip
...@@ -235,14 +235,14 @@ curl -u root:taosdata http://<FQDN>:<PORT>/rest/sql -d "select server_version()" ...@@ -235,14 +235,14 @@ curl -u root:taosdata http://<FQDN>:<PORT>/rest/sql -d "select server_version()"
上面 `TaosConnection` 类的使用示例中,我们已经展示了两种获取查询结果的方法: `fetch_all()` 和 `fetch_all_into_dict()`。除此之外 `TaosResult` 还提供了按行迭代(`rows_iter`)或按数据块迭代(`blocks_iter`)结果集的方法。在查询数据量较大的场景,使用这两个方法会更高效。 上面 `TaosConnection` 类的使用示例中,我们已经展示了两种获取查询结果的方法: `fetch_all()` 和 `fetch_all_into_dict()`。除此之外 `TaosResult` 还提供了按行迭代(`rows_iter`)或按数据块迭代(`blocks_iter`)结果集的方法。在查询数据量较大的场景,使用这两个方法会更高效。
```python title="blocks_iter 方法" ```python title="blocks_iter 方法"
{{#include docs-examples/python/result_set_examples.py}} {{#include docs/examples/python/result_set_examples.py}}
``` ```
##### TaosCursor 类的使用 ##### TaosCursor 类的使用
`TaosConnection` 类和 `TaosResult` 类已经实现了原生接口的所有功能。如果你对 PEP249 规范中的接口比较熟悉也可以使用 `TaosCursor` 类提供的方法。 `TaosConnection` 类和 `TaosResult` 类已经实现了原生接口的所有功能。如果你对 PEP249 规范中的接口比较熟悉也可以使用 `TaosCursor` 类提供的方法。
```python title="TaosCursor 的使用" ```python title="TaosCursor 的使用"
{{#include docs-examples/python/cursor_usage_native_reference.py}} {{#include docs/examples/python/cursor_usage_native_reference.py}}
``` ```
:::note :::note
...@@ -258,7 +258,7 @@ TaosCursor 类使用原生连接进行写入、查询操作。在客户端多线 ...@@ -258,7 +258,7 @@ TaosCursor 类使用原生连接进行写入、查询操作。在客户端多线
`TaosRestCursor` 类是对 PEP249 Cursor 接口的实现。 `TaosRestCursor` 类是对 PEP249 Cursor 接口的实现。
```python title="TaosRestCursor 的使用" ```python title="TaosRestCursor 的使用"
{{#include docs-examples/python/connect_rest_examples.py:basic}} {{#include docs/examples/python/connect_rest_examples.py:basic}}
``` ```
- `cursor.execute` : 用来执行任意 SQL 语句。 - `cursor.execute` : 用来执行任意 SQL 语句。
- `cursor.rowcount`: 对于写入操作返回写入成功记录数。对于查询操作,返回结果集行数。 - `cursor.rowcount`: 对于写入操作返回写入成功记录数。对于查询操作,返回结果集行数。
...@@ -269,7 +269,7 @@ TaosCursor 类使用原生连接进行写入、查询操作。在客户端多线 ...@@ -269,7 +269,7 @@ TaosCursor 类使用原生连接进行写入、查询操作。在客户端多线
`RestClient` 类是对于 [REST API](/reference/rest-api) 的直接封装。它只包含一个 `sql()` 方法用于执行任意 SQL 语句, 并返回执行结果。 `RestClient` 类是对于 [REST API](/reference/rest-api) 的直接封装。它只包含一个 `sql()` 方法用于执行任意 SQL 语句, 并返回执行结果。
```python title="RestClient 的使用" ```python title="RestClient 的使用"
{{#include docs-examples/python/rest_client_example.py}} {{#include docs/examples/python/rest_client_example.py}}
``` ```
对于 `sql()` 方法更详细的介绍, 请参考 [RestClient](https://docs.taosdata.com/api/taospy/taosrest/restclient.html)。 对于 `sql()` 方法更详细的介绍, 请参考 [RestClient](https://docs.taosdata.com/api/taospy/taosrest/restclient.html)。
...@@ -285,14 +285,14 @@ TaosCursor 类使用原生连接进行写入、查询操作。在客户端多线 ...@@ -285,14 +285,14 @@ TaosCursor 类使用原生连接进行写入、查询操作。在客户端多线
<TabItem value="native" label="原生连接"> <TabItem value="native" label="原生连接">
```python ```python
{{#include docs-examples/python/conn_native_pandas.py}} {{#include docs/examples/python/conn_native_pandas.py}}
``` ```
</TabItem> </TabItem>
<TabItem value="rest" label="REST 连接"> <TabItem value="rest" label="REST 连接">
```python ```python
{{#include docs-examples/python/conn_rest_pandas.py}} {{#include docs/examples/python/conn_rest_pandas.py}}
``` ```
</TabItem> </TabItem>
...@@ -316,7 +316,7 @@ TaosCursor 类使用原生连接进行写入、查询操作。在客户端多线 ...@@ -316,7 +316,7 @@ TaosCursor 类使用原生连接进行写入、查询操作。在客户端多线
所有数据库操作如果出现异常,都会直接抛出来。由应用程序负责异常处理。比如: 所有数据库操作如果出现异常,都会直接抛出来。由应用程序负责异常处理。比如:
```python ```python
{{#include docs-examples/python/handle_exception.py}} {{#include docs/examples/python/handle_exception.py}}
``` ```
### 关于纳秒 (nanosecond) ### 关于纳秒 (nanosecond)
......
...@@ -116,7 +116,7 @@ INSERT INTO test.sensor_data VALUES( ...@@ -116,7 +116,7 @@ INSERT INTO test.sensor_data VALUES(
## 编写模拟测试程序 ## 编写模拟测试程序
```javascript ```javascript
{{#include docs-examples/other/mock.js}} {{#include docs/examples/other/mock.js}}
``` ```
注意:代码中 CLIENT_NUM 在开始测试中可以先设置一个较小的值,避免硬件性能不能完全处理较大并发客户端数量。 注意:代码中 CLIENT_NUM 在开始测试中可以先设置一个较小的值,避免硬件性能不能完全处理较大并发客户端数量。
......
...@@ -6,7 +6,7 @@ python3 .\test.py -f 0-others\telemetry.py ...@@ -6,7 +6,7 @@ python3 .\test.py -f 0-others\telemetry.py
python3 .\test.py -f 0-others\taosdMonitor.py python3 .\test.py -f 0-others\taosdMonitor.py
python3 .\test.py -f 0-others\udfTest.py python3 .\test.py -f 0-others\udfTest.py
python3 .\test.py -f 0-others\udf_create.py python3 .\test.py -f 0-others\udf_create.py
python3 .\test.py -f 0-others\udf_restart_taosd.py @REM python3 .\test.py -f 0-others\udf_restart_taosd.py
python3 .\test.py -f 0-others\cachelast.py python3 .\test.py -f 0-others\cachelast.py
python3 .\test.py -f 0-others\user_control.py python3 .\test.py -f 0-others\user_control.py
...@@ -82,7 +82,7 @@ python3 .\test.py -f 2-query\elapsed.py ...@@ -82,7 +82,7 @@ python3 .\test.py -f 2-query\elapsed.py
python3 .\test.py -f 2-query\csum.py python3 .\test.py -f 2-query\csum.py
python3 .\test.py -f 2-query\mavg.py python3 .\test.py -f 2-query\mavg.py
python3 .\test.py -f 2-query\diff.py python3 .\test.py -f 2-query\diff.py
python3 .\test.py -f 2-query\sample.py @REM python3 .\test.py -f 2-query\sample.py
python3 .\test.py -f 2-query\function_diff.py python3 .\test.py -f 2-query\function_diff.py
python3 .\test.py -f 2-query\unique.py python3 .\test.py -f 2-query\unique.py
python3 .\test.py -f 2-query\stateduration.py python3 .\test.py -f 2-query\stateduration.py
...@@ -91,7 +91,7 @@ python3 .\test.py -f 2-query\statecount.py ...@@ -91,7 +91,7 @@ python3 .\test.py -f 2-query\statecount.py
python3 .\test.py -f 7-tmq\basic5.py python3 .\test.py -f 7-tmq\basic5.py
python3 .\test.py -f 7-tmq\subscribeDb.py python3 .\test.py -f 7-tmq\subscribeDb.py
python3 .\test.py -f 7-tmq\subscribeDb0.py @REM python3 .\test.py -f 7-tmq\subscribeDb0.py
python3 .\test.py -f 7-tmq\subscribeDb1.py python3 .\test.py -f 7-tmq\subscribeDb1.py
python3 .\test.py -f 7-tmq\subscribeStb.py python3 .\test.py -f 7-tmq\subscribeStb.py
python3 .\test.py -f 7-tmq\subscribeStb0.py python3 .\test.py -f 7-tmq\subscribeStb0.py
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册