Greetings,
I am using SQLAlchemy==1.3.18.
I have an SQLAlchemy "Settings" table with a "data" column defined as:
from sqlalchemy.dialects.postgresql import JSONB
Settings = Table(
"settings",
self._metadata,
# ...
Column("data", JSONB, nullable=False))
and later in the code this "baked" query:
from sqlalchemy.dialects.postgresql import insert as pinsert, JSONB
query = (
pinsert(Settings)
.values({
"key": "xxx",
"data": bindparam("timestamps", type_=JSONB)})
.on_conflict_do_update(
index_elements=(Settings.columns.key,),
set_=bindparam("timestamps", type_=JSONB))
The python interpreter throws me the following error raised by sqlalchemy.dialects.postgresql.dml line 227:
if not isinstance(set_, dict) or not set_:
raise ValueError("set parameter must be a non-empty dictionary")
it seems that the "set_" parameter of the "on_conflict_do_update" method requires a dict, and thus is not compatible with bindparam.
I have also tried to set the "type_" parameter of bindparam to dict, but I did not solve the problem.
Please, can anybody help me?