Re: [sqlalchemy] Callback for when orm data is load

2021-04-30 Thread Mike Bernson
Looking at the code in loading I see where instance  state is getting set to unmodified. attr.py in _instance at line 975:     if effective_populate_existing or state.modified:     if refresh_state and only_load_props:     state._commit(dict_, only_

Re: [sqlalchemy] Callback for when orm data is load

2021-04-30 Thread Mike Bernson
The load and refresh events is close to what I am looking for. I need to be able to modify attribute of object/instance that have been load or refreshed. I can not do the work in load or refresh event because any changes made in the events are not track and written out on a flush/commit. . I am u

Re: [sqlalchemy] Callback for when orm data is load

2021-04-27 Thread Mike Bayer
they're created as the result object is iterated, which is up to how the end user handles the result. there's a not-yet documented execution option you can use to prebuffer the rows: orm_execute_state.update_execution_options(prebuffer_rows=True) result = orm_execute_state.invoke_stateme

Re: [sqlalchemy] Callback for when orm data is load

2021-04-27 Thread Mike Bernson
That callback look like it happening before orm instances are created. I am looking for a callback that is after all the instances are created. I am using the events to get a list of instances that need work done when they are loaded from the database. I need the instance data and relationship

Re: [sqlalchemy] Callback for when orm data is load

2021-04-27 Thread Mike Bayer
the event that corresponds most directly here is the do_orm_execute() event: https://docs.sqlalchemy.org/en/14/orm/session_events.html#session-execute-events you would want to use the "re-execute statement" feature described at: https://docs.sqlalchemy.org/en/14/orm/session_events.html#re-execu

[sqlalchemy] Callback for when orm data is load

2021-04-27 Thread Mike Bernson
I am moving from version 1.0.14 to version 1.4.11 of sqlalchemy. I need to get a callback when all of the data from orm query is loaded not just single instance. In the 1.0 version I created the session using query_cls: self.session = Session(bind=engine, autoflush=False,    _enable_transa