Apache NiFi - 将 XML 数据插入 Postgres
Apache NiFi - Insert XML data to Postgres
我有一个简单的要求。我需要使用 NiFi 将 xml 数据插入到相应的 Postgres table 中。这一步一步的方法是什么?
谢谢!
您可以使用 TransformXml processor with an XSLT to transform your XML to JSON. If your XML/JSON is "flat", meaning you have only one level of fields in your outgoing JSON, you can use ConvertJSONToSQL followed by PutSQL to insert the records into your database. If your JSON is not flat and you want to transform it into a flat object (for the convert/put part), you can use JoltTransformJSON 来做到这一点。
在 NiFi 1.2.0 中,您可以将 ConvertJSONToSQL -> PutSQL 部分替换为 PutDatabaseRecord;您可以设置 JsonPathReader 或 JsonTreeReader 来获取记录。目前还没有 XML 记录 Reader,但在 1.2.0 中有一个 ScriptedRecordReader 和一个 example Groovy script 用于在平面 XML 文件中读取。
我有一个简单的要求。我需要使用 NiFi 将 xml 数据插入到相应的 Postgres table 中。这一步一步的方法是什么?
谢谢!
您可以使用 TransformXml processor with an XSLT to transform your XML to JSON. If your XML/JSON is "flat", meaning you have only one level of fields in your outgoing JSON, you can use ConvertJSONToSQL followed by PutSQL to insert the records into your database. If your JSON is not flat and you want to transform it into a flat object (for the convert/put part), you can use JoltTransformJSON 来做到这一点。
在 NiFi 1.2.0 中,您可以将 ConvertJSONToSQL -> PutSQL 部分替换为 PutDatabaseRecord;您可以设置 JsonPathReader 或 JsonTreeReader 来获取记录。目前还没有 XML 记录 Reader,但在 1.2.0 中有一个 ScriptedRecordReader 和一个 example Groovy script 用于在平面 XML 文件中读取。