SQLAlchemy equivalent to SQL “LIKE” statement

前端 未结 5 674
借酒劲吻你
借酒劲吻你 2020-12-02 21:50

A tags column has values like \"apple banana orange\" and \"strawberry banana lemon\". I want to find the SQLAlchemy equivalent statement to

SELECT * FROM ta         


        
5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-02 22:22

    Adding to the above answer, whoever looks for a solution, you can also try 'match' operator instead of 'like'. Do not want to be biased but it perfectly worked for me in Postgresql.

    Note.query.filter(Note.message.match("%somestr%")).all()
    

    It inherits database functions such as CONTAINS and MATCH. However, it is not available in SQLite.

    For more info go Common Filter Operators

提交回复
热议问题