Re: [sqlalchemy] session.merge() and detecting insertions and updates within the context of an HTTP handler

2019-01-11 Thread HP3
Thank you very much Mike! with session.no_autoflush: > obj = session.merge(my_thing) > for r in session.new: > > for r in session.dirty: > ... > session.new is showing the newly added :) I'll need to experiment more to make sure all my cases are covered.

Re: [sqlalchemy] Orm models, transaction and multiple binds

2019-01-11 Thread Mike Bayer
On Fri, Jan 11, 2019 at 1:19 PM tonthon wrote: > > Hi, > > We're using Sqlalchemy in a Pyramid web application, with the pyramid_tm > package (a transaction that wraps every web request inside a DB transaction). > It's very usefull and it works like a charm. > > In order to follow some security

[sqlalchemy] Re: Orm models, transaction and multiple binds

2019-01-11 Thread Jonathan Vanasco
I don't think you can accomplish this with pyramid_tm being used. My initial response was going to be this: since session_1 is readonly, don't configure it to join the pyramid_tm/zope transaction. Then just rollback session_1 when session_2 commits. but session_2 is going to commit

[sqlalchemy] Orm models, transaction and multiple binds

2019-01-11 Thread tonthon
Hi, We're using Sqlalchemy in a Pyramid web application, with the pyramid_tm package (a transaction that wraps every web request inside a DB transaction). It's very usefull and it works like a charm. In order to follow some security rules and to be able to certify part of our app, we want to

Re: [sqlalchemy] session.merge() and detecting insertions and updates within the context of an HTTP handler

2019-01-11 Thread Mike Bayer
On Fri, Jan 11, 2019 at 11:39 AM HP3 wrote: > > Hello all, > > I'm using `session.merge()` within an HTTP handler, I would like to know > which objects have been newly added and which ones have been modified after > `merge()` completes. as you tried, the easiest way is to look in session.new

[sqlalchemy] session.merge() and detecting insertions and updates within the context of an HTTP handler

2019-01-11 Thread HP3
Hello all, I'm using `session.merge()` within an HTTP handler, I would like to know which objects have been newly added and which ones have been modified after `merge()` completes. Bare with me please ... I know there are `before_flush`, etc. events exactly for this scenario but I **only**

Re: Can I ignore it when the result of the generation is empty?

2019-01-11 Thread Mike Bayer
one thing to note with "empty" migrations is that autogenerate does not pick up things like changes of server default or datatypes unless you set some flags to turn it on,

Can I ignore it when the result of the generation is empty?

2019-01-11 Thread jackadam1981
Can I ignore it when the result of the generation is empty? I use it in docker, there is a startup command to upgrade the database version to the latest. The database version is updated at startup and a record update version_num is generated. Sorry for my bad English from alembic import op