Reputation: 883
I have a flow Getfile -> PutDatabaseRecord and I have a CSV with fields as follows :
Module No, Pos, Machine Name, Machine Type
I want to ingest the value for these fields in my database table 'Test' that has fields describes as:
Module_No,Pos,Machine_Name,Machine_Type
So here is a change in fields name. What setting to set in the Putdatabaserecord to successfully ingest the data into mysql table.
Right now I am getting error as Module No cannot be null. How can I fix this change of header names in the original CSV and MySQL table. Thank you!
Upvotes: 3
Views: 4663
Reputation: 12083
In PutDatabaseRecord, you can configure your schema to use the field names as they appear in the database, and ignore the header names (which are slightly different). If you are using Get String Fields From Header
as your Schema Access Strategy, change this to Use Schema Text
and put the following in the Schema Text property:
{
"namespace": "nifi",
"name": "machine",
"type": "record",
"fields": [
{"name": "Module_No","type": "string"},
{"name": "Pos","type": "string"},
{"name": "Machine_Name","type": "string"},
{"name": "Machine_Type","type": "string"}
]
}
Then set Treat First Line As Header
to true
and set Ignore CSV Header Column Names
to true
. Then the records will be read in using the explicit field names, which match the columns in your DB, and the processor should work correctly.
Upvotes: 9