Use or_ () and like() , the following code should satisfy your need well:
from sqlalchemy import or_ foo = ['a%', 'b%'] DBSession().query(MyTable).filter(or_(*[MyTable.my_column.like(name) for name in foo]))
A, where the WHERE my_column LIKE 'a%' OR my_column LIKE 'b%' will be generated from the code above.
As for why your any() did not work, I think because it requires my_column list (see here ), and for instance query(MyTable).filter(MyTable.my_list_column.any(name='abc')) should return MyTable rows if any element in the my_list_column column (list) of this row has a name with 'abc', so it really is very different from your need.
source share