[sqlalchemy] How to use user defined python function inside a sqlalchemy filter?

2021-04-27 Thread Gyanaranjan Nayak
I have a function with name is_id_valid(id) which returns either True or False. I want to pass this function inside a sqlalchemy query inside the filter condition. My query example is : a = session.query(GeneralBeqReq).filter(GeneralBeqReq.c.BeqReqStatus == 1, is_id_valid

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 =

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:

[sqlalchemy] Issue with relationship

2021-04-27 Thread Emanuel Vitorino
Hi all I've updated an old sql alchemy powered application and I'm struggling with a relationship issue. Having this code: class Member(object): _data_provider = inject.attr(DataProvider) def __init__(self, id_member=None, name=None): self.id_member = id_member self.name = name

[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,