Issue
I have a list of values and I want to filter this sqlalchemy query based on if a value is in that list. Something like this:
def get_values(db: Session=
l = [23, 34, 54]
qr = db.query(table).filter(table.column in l).all()
return qr
Thanks
Solution
You can use the in_ method on columns:
qr = db.query(table).filter(Model.column_id.in_(l)).all()
(Make sure you keep the underscore (_) at the end of in)
Answered By - MatsLindh Answer Checked By - Cary Denson (sql.easybugfix Admin)
Post a Comment
Post a Comment