Insert JSON into databases
JSON is the main data format used in Skyone Studio and you may often want to write several data records from a JSON array to a relational database.
You can always process each element of the array individually and use a regular INSERT to store the record in the database. However, most databases have tools for receiving a JSON array as an argument to a function that maps the array elements to the database columns. These functions allow us to pass large JSON arrays to a single INSERT, saving time and processing from platform flows.
JSON Source
As an example, consider the array of trades extracted from CoinAPI:
Trades array (<>trades</>)
We usually want to INSERT the whole array in a single database operation.
Postgres
Let's assume we have the database trades already created with the column names identical as the property names of the trades array.
In the query field onf the database operation you can configure:
Where <>trades</> is a parameter that contain the array as specified above.
Oracle
Let's assume we have the database trades already created with the column names identical as the property names of the trades array.
In the query field onf the database operation you can configure:
Where <>trades</> is a parameter that contain the array as specified above.
Observe we have to use the variable my_array to store the original JSON array. This is required to handle with arrays larger then 4000 charactes.
MS SQL
Let's assume we have the database trades already created with the column names identical as the property names of the trades array.
In the query field onf the database operation you can configure:
Where <>trades</> is a parameter that contain the array as specified above.
If your JSON has strings with single quotes as part of the text, you may need to escape them by duplicating the single quotes. The MS SQL will store a single quote instead
Last updated