I have a FlowFile and I want to insert the attributes into RDS. If this was a local machine, I'd create a DBCPConnectionPool, reference a JDBC driver, etc.
With RDS, what am I supposed to do? Something similar (how would I do this on AWS)? Or am I stuck using ExecuteScript? If it's the later, is there a Python example for how to do this?
Question might not have been clear based on the feedback, but here is the answer to get a NiFi (running on an AWS EC2 instance) communicating with an Amazon RDS instance:
wget "https://driver.jar"
) readlink -f driver.jar
to get the path). assume that all the values that you want to insert into database are in flowfile attributes.
use ReplaceText
processor to replace content of the flow file with sql insert statement:
insert into mytable (id, message, start_date) values(?, ?, ?)
then use PutSQL
processor with following properties to specify three parameters ( ?
) of sql statement
sql.args.1.type = 2 # NUMERIC
sql.args.1.value = ${MY_ATTR_ID} # get value from attribute or context variable MY_ATTR_ID
sql.args.2.type = 12 # VARCHAR
sql.args.2.value = ${MY_ATTR_MSG}
sql.args.3.type = 93 # TIMESTAMP
sql.args.3.value = ${MY_ATTR_DATE}
sql.args.3.format = yyyy-MM-dd HH:mm:ss.SSS
all the jdbc data types are listed here:
https://docs.oracle.com/javase/7/docs/api/constant-values.html#java.sql.Types.ARRAY
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.