如何在 sqlalchemy ORM 查询中传递一个 not like 运算符 [英] how to pass a not like operator in a sqlalchemy ORM query

查看:39
本文介绍了如何在 sqlalchemy ORM 查询中传递一个 not like 运算符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个查询:

MyModel.query.filter(Mymodel.name.contains('a_string'))

我需要使用否定(not like 运算符)执行相同的查询,但在 SQLAlchemy 文档.

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.

有没有什么办法可以不用SQLAlchemy的sql部分???

Is there any way to do it without using the sql part of SQLAlchemy???

推荐答案

只需否定过滤器:

MyModel.query.filter(sqlalchemy.not_(Mymodel.name.contains('a_string')))

这篇关于如何在 sqlalchemy ORM 查询中传递一个 not like 运算符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆