@@ -20,6 +20,11 @@ The source code for the Python connector is hosted on [GitHub](https://github.co
...
@@ -20,6 +20,11 @@ The source code for the Python connector is hosted on [GitHub](https://github.co
- The [supported platforms](/reference/connector/#supported-platforms) for the native connection are the same as the ones supported by the TDengine client.
- The [supported platforms](/reference/connector/#supported-platforms) for the native connection are the same as the ones supported by the TDengine client.
- REST connections are supported on all platforms that can run Python.
- REST connections are supported on all platforms that can run Python.
### Supported features
- Native connections support all the core features of TDengine, including connection management, SQL execution, bind interface, subscriptions, and schemaless writing.
- REST connections support features such as connection management and SQL execution. (SQL execution allows you to: manage databases, tables, and supertables, write data, query data, create continuous queries, etc.).
## Version selection
## Version selection
We recommend using the latest version of `taospy`, regardless of the version of TDengine.
We recommend using the latest version of `taospy`, regardless of the version of TDengine.
...
@@ -64,10 +69,23 @@ All exceptions from the Python Connector are thrown directly. Applications shoul
...
@@ -64,10 +69,23 @@ All exceptions from the Python Connector are thrown directly. Applications shoul
- Native connections support all the core features of TDengine, including connection management, SQL execution, bind interface, subscriptions, and schemaless writing.
TDengine currently supports timestamp, number, character, Boolean type, and the corresponding type conversion with Python is as follows:
- REST connections support features such as connection management and SQL execution. (SQL execution allows you to: manage databases, tables, and supertables, write data, query data, create continuous queries, etc.).
|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|
## Installation
## Installation
...
@@ -544,7 +562,7 @@ Connector support data subscription. For more information about subscroption, pl
...
@@ -544,7 +562,7 @@ Connector support data subscription. For more information about subscroption, pl
The `consumer` in the connector contains the subscription api.
The `consumer` in the connector contains the subscription api.
#### Create Consumer
##### Create Consumer
The syntax for creating a consumer is `consumer = Consumer(configs)`. For more subscription api parameters, please refer to [Data Subscription](../../../develop/tmq/).
The syntax for creating a consumer is `consumer = Consumer(configs)`. For more subscription api parameters, please refer to [Data Subscription](../../../develop/tmq/).
The `subscribe` function is used to subscribe to a list of topics.
The `subscribe` function is used to subscribe to a list of topics.
...
@@ -562,7 +580,7 @@ The `subscribe` function is used to subscribe to a list of topics.
...
@@ -562,7 +580,7 @@ The `subscribe` function is used to subscribe to a list of topics.
consumer.subscribe(['topic1', 'topic2'])
consumer.subscribe(['topic1', 'topic2'])
```
```
#### Consume
##### Consume
The `poll` function is used to consume data in tmq. The parameter of the `poll` function is a value of type float representing the timeout in seconds. It returns a `Message` before timing out, or `None` on timing out. You have to handle error messages in response data.
The `poll` function is used to consume data in tmq. The parameter of the `poll` function is a value of type float representing the timeout in seconds. It returns a `Message` before timing out, or `None` on timing out. You have to handle error messages in response data.
...
@@ -580,7 +598,7 @@ while True:
...
@@ -580,7 +598,7 @@ while True:
print(block.fetchall())
print(block.fetchall())
```
```
#### assignment
##### assignment
The `assignment` function is used to get the assignment of the topic.
The `assignment` function is used to get the assignment of the topic.
...
@@ -588,7 +606,7 @@ The `assignment` function is used to get the assignment of the topic.
...
@@ -588,7 +606,7 @@ The `assignment` function is used to get the assignment of the topic.
assignments = consumer.assignment()
assignments = consumer.assignment()
```
```
#### Seek
##### Seek
The `seek` function is used to reset the assignment of the topic.
The `seek` function is used to reset the assignment of the topic.
In addition to native connections, the connector also supports subscriptions via websockets.
In addition to native connections, the connector also supports subscriptions via websockets.
#### Create Consumer
##### Create Consumer
The syntax for creating a consumer is "consumer = consumer = Consumer(conf=configs)". You need to specify that the `td.connect.websocket.scheme` parameter is set to "ws" in the configuration. For more subscription api parameters, please refer to [Data Subscription](../../../develop/tmq/#create-a-consumer).
The syntax for creating a consumer is "consumer = consumer = Consumer(conf=configs)". You need to specify that the `td.connect.websocket.scheme` parameter is set to "ws" in the configuration. For more subscription api parameters, please refer to [Data Subscription](../../../develop/tmq/#create-a-consumer).
The `subscribe` function is used to subscribe to a list of topics.
The `subscribe` function is used to subscribe to a list of topics.
...
@@ -642,7 +660,7 @@ The `subscribe` function is used to subscribe to a list of topics.
...
@@ -642,7 +660,7 @@ The `subscribe` function is used to subscribe to a list of topics.
consumer.subscribe(['topic1', 'topic2'])
consumer.subscribe(['topic1', 'topic2'])
```
```
#### Consume
##### Consume
The `poll` function is used to consume data in tmq. The parameter of the `poll` function is a value of type float representing the timeout in seconds. It returns a `Message` before timing out, or `None` on timing out. You have to handle error messages in response data.
The `poll` function is used to consume data in tmq. The parameter of the `poll` function is a value of type float representing the timeout in seconds. It returns a `Message` before timing out, or `None` on timing out. You have to handle error messages in response data.
...
@@ -659,7 +677,7 @@ while True:
...
@@ -659,7 +677,7 @@ while True:
print(row)
print(row)
```
```
#### assignment
##### assignment
The `assignment` function is used to get the assignment of the topic.
The `assignment` function is used to get the assignment of the topic.
...
@@ -667,7 +685,7 @@ The `assignment` function is used to get the assignment of the topic.
...
@@ -667,7 +685,7 @@ The `assignment` function is used to get the assignment of the topic.
assignments = consumer.assignment()
assignments = consumer.assignment()
```
```
#### Seek
##### Seek
The `seek` function is used to reset the assignment of the topic.
The `seek` function is used to reset the assignment of the topic.
...
@@ -675,7 +693,7 @@ The `seek` function is used to reset the assignment of the topic.
...
@@ -675,7 +693,7 @@ The `seek` function is used to reset the assignment of the topic.