'dynamic' is special and can be useful if you have many items and always want to apply additional SQL filters to them. Instead of loading the items SQLAlchemy will return another query object which you can further refine before loading the items. Note that this cannot be turned into a different loading strategy when querying so it’s often a good idea to avoid using this in favor of lazy=True. A query object equivalent to a dynamic user.addresses relationship can be created using Address.query.with_parent(user) while still being able to use lazy or eager loading on the relationship itself as necessary.
Some example code using the with_parent()
ab_cnt = session.query(ScheduleEntry).with_parent(sch).filter_by(Â ent_enabled=1).filter(spm >= ScheduleEntry.on_spm).filter(spm <= ScheduleEntry.off_spm).count()












