Answer the question
In order to leave comments, you need to log in
How to write an array of dictionaries to JSONB?
Tell me, I have formed an array of dictionaries and I want to put this array in a JSONB field. How to do it?
Answer the question
In order to leave comments, you need to log in
From documentation :
from psycopg2.extras import Json
data = [
{'a': 1},
{'b': 2},
{'c': 3, 'z': None}
]
curs.execute("insert into mytable (jsondata) values (%s)", [Json(data)])
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question