How to write JSON data into SQL table

Day 4:

Today we are going to see how to read a JSON file and write it into a SQL table.

We can get files into nifi flow by using the GetFile processor. 

No alt text provided for this image


No alt text provided for this image

In the highlighted areas we have to mention the input file directory. If we keep a false in “Keep Source File” property processor will remove source else if we keep true then processor won’t remove source file.

The next step is to extract data from JSON files. By using the EvaluateJsonPath processor, we can convert json data into flowfile attributes.

No alt text provided for this image

In the example below, we have two keys and values,

{

“name”:”abc”,

“id”:”1”

}

To extract values from them we have to call keys like below,

Name = $.name

Id = $.id

No alt text provided for this image

While constructing queries called flowfile attributes in place of values, we can insert JSON values into DB.

Please refer to my previous post for inserting data into SQL DB.

https://www.garudax.id/posts/rajadurairamasamy_dataengineering-dataengineer-pipelines-activity-7063507308789563392-ai6L?utm_source=share&utm_medium=member_desktop


To view or add a comment, sign in

More articles by Rajadurai Ramasamy

Explore content categories