未验证 提交 a91c247a 编写于 作者: W wade zhang 提交者: GitHub

Merge pull request #11927 from taosdata/docs/wade-20220427-c++

docs: remove redundant sample code in c++ connector and change sample order to be consistent with API
......@@ -94,29 +94,29 @@ TDengine 客户端驱动的安装请参考 [安装指南](/operation/pkg-install
</details>
### 订阅和消费示例
### 无模式写入示例
<details>
<summary>订阅和消费</summary>
<summary>无模式写入</summary>
```c++
{{#include examples/c/subscribe.c}}
{{#include examples/c/schemaless.c}}
```
</details>
### 无模式写入示例
### 订阅和消费示例
<details>
<summary>无模式写入</summary>
<summary>订阅和消费</summary>
```c++
{{#include examples/c/schemaless.c}}
{{#include examples/c/subscribe.c}}
```
</details>
:::info
更多示例代码及下载请见 [github](https://github.com/taosdata/TDengine/tree/develop/examples/c)
也可以在安装目录下的 examples/c 路径下找到。 该目录下有 makefile,在 Linux 环境下,直接执行 make 就可以编译得到执行文件。
......@@ -402,39 +402,6 @@ TDengine 的异步 API 均采用非阻塞调用模式。应用程序可以用多
**支持版本**
该功能接口从 2.3.0.0 版本开始支持。
```c
#include <stdlib.h>
#include <stdio.h>
#include <taos.h>
int main() {
const char* host = "127.0.0.1";
const char* user = "root";
const char* passwd = "taosdata";
// connect to server
TAOS* taos = taos_connect(host, user, passwd, "test", 0);
// prepare the line string
char* lines1[] = {
"stg,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000",
"stg,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64 1626006833641000000"
};
// schema-less insert
TAOS_RES* res = taos_schemaless_insert(taos, lines1, 2, TSDB_SML_LINE_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS);
if (taos_errno(res) != 0) {
printf("failed to insert schema-less data, reason: %s\n", taos_errstr(res));
}
taos_free_result(res);
// close the connection
taos_close(taos);
return (code);
}
```
### 订阅和消费 API
订阅 API 目前支持订阅一张或多张表,并通过定期轮询的方式不断获取写入表中的最新数据。
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册