Hi there, I just started to learn SQLAlchemy. 0 <https://stackoverflow.com/posts/70266906/timeline>
I have a `on_conflict_do_update` command as follows: ``` insert_stmt = insert(MessageSymbol).values(message_id=12345, symbol_id=1) do_update_stmt = insert_stmt.on_conflict_do_update( index_elements=['message_id'], set_=dict( symbol_id=123 ) ) ``` and my MessageSymbol is defined as follow: ``` class MessageSymbol(Base): __tablename__ = "message_symbol" message_id = Column(BigInteger, primary_key=True, nullable=False) symbol_id = Column(BigInteger, nullable=False) ``` When the command is executed it throws the error: ``` sqlalchemy.exc.ProgrammingError: (psycopg2.errors.InvalidColumnReference) there is no unique or exclusion constraint matching the ON CONFLICT specification [SQL: INSERT INTO message_symbol (message_id, symbol_id) VALUES (%(message_id)s, %(symbol_id)s) ON CONFLICT (message_id) DO UPDATE SET symbol_id = %(param_1)s] [parameters: {'message_id': 12345, 'symbol_id': 1, 'param_1': 123}] ``` Since I have defined the `message_id` as the primary key I assume it should be a unique constraint. I am wondering what else is being missing? Chaozy -- 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 sqlalchemy+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sqlalchemy/c0957df9-aef1-47db-b94e-ed29c0bde0d1n%40googlegroups.com.