I want to override my `Session` such that it performs and `INSERT ON CONFLICT` whenever I `add` an object.
`merge` is too slow for my use-case: it has to perform a `SELECT` first, and I want to reduce my latency as much as I can. Currently this is the standard behaviour: user = User(id=1, name='John') # suppose we already have a record with id=1 session.add(user) # this tries to INSERT, which will raise an Integrity error session.commit() I want to be able to do something like this: user = User(id=1, name='John', update=True) session.add(user) # this now does INSERT ON CONFLICT DO UPDATE SET ... session.commit() and if `update=False` then perform `DO NOTHING` I assume I will need to monkey-patch around the Insert class but I am not 100% sure. Any idea how to achieve this in an elegant way? -- 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 post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at https://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.