Category: sqlalchemy

Problem

Query ORM models with a session.

Solution

  users = session.query(User).filter(User.active == True).all()
  

Notes

  • Adapt variable names and paths to your project
  • Add error handling for production use
  • See related chapters in the Learning Path