SQLAlchemy - Full Boot Instance Before Disconnecting

Is there a way to fully load an instance of the mapped SQLAlchemy ORM (along with its associated objects) before disconnecting it from the session? I want to send it via pipe to other processes, and I do not want to join it into a session in this new process.

Thanks, Jan

+5
source share
1 answer

I suggest that you want to use the method in the request with or . options()eagerload()eagerload_all()

, Controlled , changes, DocumentChange, dco, dco . , eagerload_all(). declarative ( , ), m.Session - (thread-local).

from sqlalchemy.orm import eagerload, eagerload_all
...
controlled_docs = (m.Session.query(m.Controlled)
    .options(eagerload_all('changes.dco'))
    .order_by('number')
    .all())

, , , , ORM, , , .

+2

All Articles