Re: [sqlalchemy] examples/versioned_history/history_meta.py Coalescing changes to produce a single history insert

2016-09-23 Thread Mike Bayer
On 09/23/2016 04:24 PM, HP3 wrote: I just tried cleaning up at `after_transaction_end` but the whole history stopped working. It seems like `after_transaction_create`/`after_transaction_end` surrounds the loading of a one-to-many relationship.Thus, when `after_commit` happened, the

Re: [sqlalchemy] How to bulk-insert millions of values into Oracle

2016-09-23 Thread Mike Bayer
On 09/21/2016 02:08 PM, Seth P wrote: The answer to this is probably RTFM, but I can't figure it out. Suppose I have a declarative model of the form class MyModel(Model): idx = sa.Column(sa.Integer, primary_key=True) c1 = sa.Column(sa.Float) c2 = sa.Column(sa.Integer) ...

Re: [sqlalchemy] examples/versioned_history/history_meta.py Coalescing changes to produce a single history insert

2016-09-23 Thread HP3
I just tried cleaning up at `after_transaction_end` but the whole history stopped working. It seems like `after_transaction_create`/`after_transaction_end` surrounds the loading of a one-to-many relationship.Thus, when `after_commit` happened, the `history_objects` dict had being emptied

Re: [sqlalchemy] Re: Question about collection_class=ordering_list and Bullet.slide = slide

2016-09-23 Thread HP3
Thank you very much Mike! The behavior I am getting is very strange. The test case (I posted and then removed by accident) validates the behavior of "append to list". IOW: position is correct and not None. 105 def test_backref_set(self): 106 self._setup(ordering_list('position'))

Re: [sqlalchemy] examples/versioned_history/history_meta.py Coalescing changes to produce a single history insert

2016-09-23 Thread HP3
Thank you Mike! At this point, I am cleaning session.info["history-objects"] in 'after_commit' and 'after_rollback'. I was wondering about 'after_soft_rollback` too ... (I discovered that history objects were being "re-added" when I was issuing session.rollback() so I added the cleanup there

Re: [sqlalchemy] Re: Abusing a string column as list of foreign keys (own relationship class, based on DependencyProcessor?)

2016-09-23 Thread Mike Bayer
On 09/23/2016 10:46 AM, Torsten Landschoff wrote: On Thursday, August 25, 2016 at 3:57:30 PM UTC+2, Mike Bayer wrote: that perspective this is not much of a "DependencyProcessor" problem because you have this local attribute that just contains a view (comma-separated-list of

Re: [sqlalchemy] examples/versioned_history/history_meta.py Coalescing changes to produce a single history insert

2016-09-23 Thread Mike Bayer
On 09/23/2016 10:18 AM, HP3 wrote: Hello all, Couple of weeks back (see [*]), while discussing that history_meta.py performs an update and an insert for each session.dirty object whenever session.flush() happens, Simon suggested the following solution to coalesce all changes within the same

Re: [sqlalchemy] Re: Question about collection_class=ordering_list and Bullet.slide = slide

2016-09-23 Thread Mike Bayer
The mechanism of backrefs is such that when you assign to the many-to-one side of the relationship, if the one-to-many is not loaded from the database, the "append" that you want to do does not occur at that time. When the list is not loaded, the object is placed in a queue where it will be

[sqlalchemy] Re: Question about collection_class=ordering_list and Bullet.slide = slide

2016-09-23 Thread HP3
There seems to be something else ... The following test passes which indicates that position is set as 0 right after the bullet and the slide are related: 93 def test_backref_set(self): 94 self._setup(ordering_list('position')) 95 96 #session = create_session() 97

[sqlalchemy] Re: Question about collection_class=ordering_list and Bullet.slide = slide

2016-09-23 Thread HP3
> > The test below (test/ext/test_orderinglist.py) demonstrates the behavior: > 93 def test_backref_set(self): 94 self._setup(ordering_list('position', count_from=0, 95 reorder_on_append=True)) 96 97 s1 = Slide('Slide #1') 98

[sqlalchemy] Question about collection_class=ordering_list and Bullet.slide = slide

2016-09-23 Thread HP3
Hello all, In regards to ordering_list: http://docs.sqlalchemy.org/en/rel_0_9/orm/extensions/orderinglist.html from sqlalchemy.ext.orderinglist import ordering_list Base = declarative_base() class Slide(Base): __tablename__ = 'slide' id = Column(Integer, primary_key=True) name =

[sqlalchemy] How to bulk-insert millions of values into Oracle

2016-09-23 Thread Seth P
The answer to this is probably RTFM, but I can't figure it out. Suppose I have a declarative model of the form class MyModel(Model): idx = sa.Column(sa.Integer, primary_key=True) c1 = sa.Column(sa.Float) c2 = sa.Column(sa.Integer) ... c10 = sa.Column(sa.Float) And a list of

Re: [sqlalchemy] Re: Abusing a string column as list of foreign keys (own relationship class, based on DependencyProcessor?)

2016-09-23 Thread Torsten Landschoff
Hi Mike, thanks for the reply. On Thursday, August 25, 2016 at 3:57:30 PM UTC+2, Mike Bayer wrote: > > > > well dependencyprocessor is about doing the objects in the right order, > clear. > and about invoking a command to "sync" important attributes from one > side to the other, which

[sqlalchemy] examples/versioned_history/history_meta.py Coalescing changes to produce a single history insert

2016-09-23 Thread HP3
Hello all, Couple of weeks back (see [*]), while discussing that history_meta.py performs an update and an insert for each session.dirty object whenever session.flush() happens, Simon suggested the following solution to coalesce all changes within the same transaction into a single insert and