Skip to content
Advertisement

How to send a list of data to postgresql from python and then iterate trough that list into an insert postgresql function?

I already have a python code that send the data to the postgresql function that i also created, but now i want to send a list to that function, but I’m not sure how to actually create that kind of postgresql function.

Postgresql Function that will insert one row looks like this. But i want to send a list of data from python and then loop trough that list inside of this function.

Python code looks like this

I actually dont need help with python code, only with postgresql, but i added it there just if anyone need to take a look on it.

Version of postgresql is 12.4 and version of python is 3.7

Advertisement

Answer

Small example with valid json:

But you have to be sure that you have a valid json object and all content also matches the datatypes in your tables.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement