i have query require use "or" |
operator :
mymodel.query.filter((mymodel.a== 'b') | (mymodel.b == 'c'))
that works fine. however, want conditions put in array of unkown length :
conds = [ mymodel.a== 'b', mymodel.b == 'c', mymodel.c == 'd'] mymodel.query.filter(???(conds))
thanks !
you looking or_
conds = [ mymodel.a== 'b', mymodel.b == 'c', mymodel.c == 'd']
if have above list of conditions pass them or_
from sqlalchemy import or_ mymodel.query.filter(or_(*conds))
Comments
Post a Comment