[sqlalchemy] Re: How to issue an INSERT ON CONFLICT instead of INSERT when using Session.add(my_object)

2017-11-17 Thread Jonathan Vanasco
I don't know if this will work for your usecase, but we handle a few similar situations with a nested transaction/savepoints. if an ntegrity error is raised on insert, an update is issued instead. on conflicts it takes longer than your ideal method, but it's much faster than selecting the

Re: [sqlalchemy] How to issue an INSERT ON CONFLICT instead of INSERT when using Session.add(my_object)

2017-11-17 Thread Mike Bayer
On Fri, Nov 17, 2017 at 9:17 AM, Petar wrote: > 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

[sqlalchemy] How to issue an INSERT ON CONFLICT instead of INSERT when using Session.add(my_object)

2017-11-17 Thread Petar
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 =

[sqlalchemy] ClassManager.new_instance() still undocumented, fails for polymorphic mappers

2017-11-17 Thread Torsten Landschoff
Hi Michael et al, tl;dr: I would like ClassManager.new_instance() to be made official as discussed in the old discussion and suggest it should initialize the polymorphic identity. Context === I am not sure if anybody remembers the discussion under

Re: [sqlalchemy] Confusion over session.dirty, query, and flush

2017-11-17 Thread jens . troeger
Sure. I'm working with two Pyramid/SQLAlchemy web servers, and in order to have a more convenient way of looking at the db data I wrote a small tool which essentially creates a db session, loads the server orm helper functions and sets up an environment much like a view handler functions has.