问题
I've got a query:
MyModel.query.filter(Mymodel.name.contains('a_string'))
I need to do the same query but with the negation (a not like operator) but didn't find any operator matching my need in the SQLAlchemy documentation.
Is there any way to do it without using the sql part of SQLAlchemy???
回答1:
Just negate the filter:
MyModel.query.filter(sqlalchemy.not_(Mymodel.name.contains('a_string')))
来源:https://stackoverflow.com/questions/5018694/how-to-pass-a-not-like-operator-in-a-sqlalchemy-orm-query