python

Filter query Sqlalchemy

Sqlalchemy query to filter rows of a table created using Sqlalchemy ORM.

#SINGLE CONDITION
session.query(User).filter(User.id == 10).all()

#MULTIPLE CONDITION
session.query(User).filter(User.first_name == 'hello', User.last_name == 'world').first()

#LIKE QUERY
session.query(User).filter(User.name.like('e%')).all()
Was this helpful?