Support Questions
Find answers, ask questions, and share your expertise

How to write to a database (postgresql) a json file in which the image is encoded using apache nifi?

New Contributor

I have the following json file in which an image is encoded in the photo field:

Без имени.png

I use standard processors to work with a JSON file and try to write this file to PostgreSQL using an ExecuteSQL processor (photo in bytea format). When writing directly, it gives an error that the char format was expected. How to write the encoded image to the database correctly using apache nifi?



When using ExecuteSQL processor to do CRUD actions on database tables, we should prepare the SQL statement by ourselves.

There could be plenties of ways to do such thing. One way as you mentioned is to use the raw json data  to insert/update a DB table, you might try to use PutDatabaseRecord processor, in such way, the json's structure must be flat as the avro-schema you fetched from the corresponding DB table.

; ;