PutSQL 2025.10.2.19

捆绑包

org.apache.nifi | nifi-standard-nar

描述

Executes a SQL UPDATE or INSERT command. The content of an incoming FlowFile is expected to be the SQL command to execute. The SQL command may use the ? to escape parameters. In this case, the parameters to use must exist as FlowFile attributes with the naming convention sql.args. N.type and sql.args. N.value, where N is a positive integer. The sql.args. N.type is expected to be a number indicating the JDBC Type. The content of the FlowFile is expected to be in UTF-8 format.

标签

database、insert、put、rdbms、relational、sql、update

输入要求

REQUIRED

支持敏感的动态属性

false

属性

属性

描述

批处理大小

在单次事务中放入数据库的首选 FlowFiles 数量

JDBC Connection Pool

指定用于将 JSON 消息转换为 SQL 语句的 JDBC 连接池。连接池是确定相应的数据库列类型所必需的。

Obtain Generated Keys

如果为 True,数据库自动生成的键将通过 sql.generate.key 属性添加至生成该键的 FlowFile。这可能会导致性能轻微下降,且并非所有数据库都支持此功能。

Support Fragmented Transactions

If true, when a FlowFile is consumed by this Processor, the Processor will first check the fragment.identifier and fragment.count attributes of that FlowFile. If the fragment.count value is greater than 1, the Processor will not process any FlowFile with that fragment.identifier until all are available; at that point, it will process all FlowFiles with that fragment.identifier as a single transaction, in the order specified by the FlowFiles 'fragment.index attributes. This Provides atomicity of those SQL statements. Once any statement of this transaction throws exception when executing, this transaction will be rolled back. When transaction rollback happened, none of these FlowFiles would be routed to'success '. If the <Rollback On Failure> is set true, these FlowFiles will stay in the input relationship. When the <Rollback On Failure> is set false,, if any of these FlowFiles will be routed to' retry ', all of these FlowFiles will be routed to' retry '.Otherwise, they will be routed to' failure'. If this value is false, these attributes will be ignored and the updates will occur independent of one another.

Transaction Timeout

如果 <Support Fragmented Transactions> 属性设置为 True,则指定在将带有特定 fragment.identifier 属性的所有 FlowFiles 转移到“failure”关系之前,需要等待带该标识符的所有 FlowFiles 到达的时长

database-session-autocommit

设置在所用数据库连接上的自动提交模式。如果设置为 False,则将明确提交或回滚操作(分别基于成功或失败),如果设置为 True,则驱动程序/数据库处理提交/回滚。

putsql-sql-statement

要执行的 SQL 语句。该语句可以为空,也可以是常量值,也可以使用表达式语言根据属性构建。如果指定了此属性,则无论传入的 FlowFiles 的内容如何,都将使用该属性。如果此属性为空,则传入的 FlowFile 的内容应包含有效的 SQL 语句,该语句将由处理器向数据库发出。

rollback-on-failure

Specify how to handle error. By default (false), if an error occurs while processing a FlowFile, the FlowFile will be routed to 'failure' or 'retry' relationship based on error type, and processor can continue with next FlowFile. Instead, you may want to rollback currently processed FlowFiles and stop further processing immediately. In that case, you can do so by enabling this 'Rollback On Failure' property. If enabled, failed FlowFiles will stay in the input relationship without penalizing it and being processed repeatedly until it gets processed successfully or removed by other means. It is important to set adequate 'Yield Duration' to avoid retrying too frequently.

关系

名称

描述

failure

如果无法更新数据库,则将一个 FlowFile 路由到此关系,重试此操作也会失败,例如查询无效或违反完整性约束

retry

如果无法更新数据库,则将一个 FlowFile 路由到此关系,但再次尝试操作可能会成功

success

成功更新数据库后,FlowFile 将路由到此关系

写入属性

名称

描述

sql.generated.key

如果数据库为 INSERT 语句生成了键并且“Obtain Generated Keys”属性设置为 True,则如果可能,将添加此属性以指示生成的键。并非所有数据库供应商都支持此功能。

语言: 中文