From 62d3df49d1d5513433b114dc02cc20dd22417c13 Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Mon, 30 Dec 2024 17:16:23 +0800 Subject: [PATCH] docs: remove STMT2 --- .../14-reference/05-connector/30-python.mdx | 65 ++++++++++--------- 1 file changed, 34 insertions(+), 31 deletions(-) diff --git a/docs/zh/14-reference/05-connector/30-python.mdx b/docs/zh/14-reference/05-connector/30-python.mdx index cdf63f918c..ad43ce19df 100644 --- a/docs/zh/14-reference/05-connector/30-python.mdx +++ b/docs/zh/14-reference/05-connector/30-python.mdx @@ -52,6 +52,7 @@ Python Connector 历史版本(建议使用最新版本的 `taospy`): | Python Connector 版本 | 主要变化 | TDengine 版本 | | -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------- | +| 2.7.20 | Native 支持 STMT2 写入 | - | | 2.7.19 | 支持 Apache Superset 连接 TDengine Cloud 数据源 | - | | 2.7.18 | 支持 Apache Superset 产品连接本地 TDengine 数据源 | - | | 2.7.16 | 新增订阅配置 (session.timeout.ms, max.poll.interval.ms) | - | @@ -248,41 +249,43 @@ TaosResult 对象可以通过循环遍历获取查询到的数据。 - `reqId`: 用于问题追踪。 - **异常**:操作失败抛出 `DataError` 或 `OperationalError` 异常。 -#### 参数绑定 STMT2 -- `def statement2(self, sql=None, option=None)` - - **接口说明**:使用连接对象创建 stmt2 对象 - - **参数说明** - - `sql`: 绑定的 SQL 语句,如果不为空会调用`prepare`函数 - - `option` 传入 TaosStmt2Option 类实例选项 - - **返回值**:stmt2 对象。 +#### 参数绑定 +- `fn statement(&self) -> PyResult` + - **接口说明**:使用 连接 对象创建 stmt 对象。 + - **返回值**:stmt 对象。 - **异常**:操作失败抛出 `ConnectionError` 异常。 -- `def prepare(self, sql)` - - **接口说明**:绑定预编译 sql 语句 +- `fn prepare(&mut self, sql: &str) -> PyResult<()>` + - **接口说明**:绑定预编译 sql 语句。 - **参数说明**: - - `sql`: 绑定的 SQL 语句 - - **异常**:操作失败抛出 `StatementError` 异常。 -- `def bind_param(self, tbnames, tags, datas)` - - **接口说明**:以独立数组方式绑定数据 + - `sql`: 预编译的 SQL 语句。 + - **异常**:操作失败抛出 `ProgrammingError` 异常。 +- `fn set_tbname(&mut self, table_name: &str) -> PyResult<()>` + - **接口说明**:设置将要写入数据的表名。 - **参数说明**: - - `tbnames`: 绑定表名数组,数据类型为 list - - `tags`: 绑定 tag 列值数组,数据类型为 list - - `tags`: 绑定普通列值数组,数据类型为 list - - **异常**:操作失败抛出 `StatementError` 异常 -- `def bind_param_with_tables(self, tables)` - - **接口说明**:以独立表方式绑定数据,独立表是以表为组织单位,每张表中有表名,TAG 值及普通列数值属性 + - `tableName`: 表名,如果需要指定数据库, 例如: `db_name.table_name` 即可。 + - **异常**:操作失败抛出 `ProgrammingError` 异常。 +- `fn set_tags(&mut self, tags: Vec) -> PyResult<()>` + - **接口说明**:设置表 Tags 数据, 用于自动建表。 - **参数说明**: - - `tables`: `BindTable` 独立表对象数组 - - **异常**:操作失败抛出 `StatementError` 异常。 -- `def execute(self) -> int:` - - **接口说明**:执行将绑定数据全部写入 - - **返回值**:影响行数 + - `paramsArray`: Tags 数据。 + - **异常**:操作失败抛出 `ProgrammingError` 异常。 +- `fn bind_param(&mut self, params: Vec) -> PyResult<()>` + - **接口说明**:绑定数据。 + - **参数说明**: + - `paramsArray`: 绑定数据。 + - **异常**:操作失败抛出 `ProgrammingError` 异常。 +- `fn add_batch(&mut self) -> PyResult<()>` + - **接口说明**:提交绑定数据。 + - **异常**:操作失败抛出 `ProgrammingError` 异常。 +- `fn execute(&mut self) -> PyResult` + - **接口说明**:执行将绑定的数据全部写入。 + - **返回值**:写入条数。 - **异常**:操作失败抛出 `QueryError` 异常。 -- `def result(self)` - - **接口说明**: 获取参数绑定查询结果集 - - **返回值**:返回 TaosResult 对象 -- `def close(self)` - - **接口说明**: 关闭 stmt2 对象 - +- `fn affect_rows(&mut self) -> PyResult` + - **接口说明**: 获取写入条数。 + - **返回值**:写入条数。 +- `fn close(&self) -> PyResult<()>` + - **接口说明**: 关闭 stmt 对象。 #### 数据订阅 @@ -424,7 +427,7 @@ TaosResult 对象可以通过循环遍历获取查询到的数据。 - **返回值**:影响的条数。 - **异常**:操作失败抛出 `SchemalessError` 异常。 -#### 参数绑定 STMT2 +#### 参数绑定 - `def statement2(self, sql=None, option=None)` - **接口说明**:使用连接对象创建 stmt2 对象 - **参数说明**