python

Like query Sqlalchemy

Like query in Sqlalchemy can be used to find records that have specific keywords based on the query.

#record has 'test' keyword on any position
session.query(User).filter(User.first_name.like('%test%')).all()

#record has 'test' keyword on first position
session.query(User).filter(User.first_name.like('test%')).all()

#record has 'test' keyword on last position
session.query(User).filter(User.first_name.like('%test')).all()
Was this helpful?