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?

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/CADKhPGT_mze%2BgjD%3DYoNd7tPGtpYMNnreKne%3DgwWMuJMZ0g2-xw%40mail.gmail.com.

Reply via email to