I am a bit stuck and the solutions I can think of will end in spaghetti code.
I am having the following JSON, I create an object of it in python 3 and I have to insert the values into PostgreSQL.
{
"name": "test",
"country": "DE",
"time": "21-Oct-2019 (09:58:01.694763)",
"toCurrency": ["EUR", "USD", "GBP"],
"fromCurrency": ["DKK", "DKK", "DKK"],
"buyMargin": ["1.2800", "1.2800", "2.0000"],
"sellMargin": ["1.2800", "1.2800", "2.0000"],
"unit": "M100"
}
I am getting the exception: can only concatenate str (not "list") to str
- How can I iterate through those lists in Python and insert one value at a time?
At the same time the other values of 'name', 'country', 'time' should be inserted every time.
Currently I can insert this JSON:
{
"name": "test",
"country": "DE",
"time": "21-Oct-2019 (09:58:01.694763)",
"toCurrency": "EUR",
"fromCurrency": "DKK",
"buyMargin": "1.2800",
"sellMargin": "1.2800",
"unit": "M100"
}

jsoncolumn or they have to be parsed and inserted in 8 different columns?