SQLAlchemy filter query “column LIKE ANY (array)”

后端 未结 2 1590
清歌不尽
清歌不尽 2020-12-09 18:23

Hi SQLAlchemy experts out there, here\'s a tricky one for you:

I\'m trying to write a query that resolves into something like:

SELECT * FROM MyTable          


        
2条回答
  •  难免孤独
    2020-12-09 19:27

    You can try to use any_()

    In your case it would look something like this:

    from sqlalchemy import any_
    
    foo = ['a%', 'b%']
    DBSession().query(MyTable).filter(MyTable.my_column.like(any_(foo)))
    

提交回复
热议问题