peewee Model.get的复杂查询
(a | b )&c
官方文档没有具体讲到,又没有太多时间来看源码。经过尝试,
(a | b) and c
(a or b) and c
都是可以的。
而 (a | b) &c 是不行的
(a or b)&c 也不行。
=====================
后记:上面的错了。peewee的Model.get不支持条件的or操作。
and操作用逗号代替。
=======
备注:or可以写进去,但出来的东西很奇怪
and也可以连着写。出来的结果不对。
-----------------------------------------
后记:
peewee的sql操作符对应:http://peewee.readthedocs.org/en/latest/peewee/querying.html#query-operators
Comparison | Meaning |
---|---|
== | x equals y |
< | x is less than y |
<= | x is less than or equal to y |
> | x is greater than y |
>= | x is greater than or equal to y |
!= | x is not equal to y |
<< | x IN y, where y is a list or query |
>> | x IS y, where y is None/NULL |
% | x LIKE y where y may contain wildcards |
** | x ILIKE y where y may contain wildcards |
~ | Negation |
sqlQuery.where中的or操作demo(这个总是忘):
Tweet.select().join(User).where(
(User.is_staff == True) | (User.is_superuser == True)
peewee Model.get的复杂查询的更多相关文章
- ThinkPHP讲解(五)——数据库配置及Model数据模型层、查询
数据库配置 在TP框架中要进行连接数据库操作,要进行配置 要在convertion.php中找到“数据库配置”,并复制到项目配置文件config.php中 Model模型层制作 model:数据库中每 ...
- 查询的model里面 一般都要有一个要返回的model做属性 ;查询前要传入得参数,查询后返回的参数 都要集合在一个model中
查询的model里面 一般都要有一个要返回的model做属性
- django中Model表的反向查询
很多时候需要在多张表之间进行跨表查询,这其中外键是必须存在的,而通过外键所处的表的对象进行跨表查询, 称为正向查询.反之,则是反向查询. 正向查询很简单,这里不谈. 主要谈下反向查询. class U ...
- Django进阶Model篇007 - 聚集查询和分组查询
接着前面的例子,举例聚集查询和分组查询例子如下: 1.查询人民邮电出版社出了多少本书 >>> Book.objects.filter(publisher__name='人民邮电出版社 ...
- 2016/05/10 thinkphp 3.2.2 ①系统常量信息 ②跨控制器调用 ③连接数据库配置及Model数据模型层 ④数据查询
[系统常量信息] 获取系统常量信息: 如果加参数true,会分组显示: 显示如下: [跨控制器调用] 一个控制器在执行的时候,可以实例化另外一个控制,并通过对象访问其指定方法. 跨控制器调用可以节省我 ...
- flask_sqlalchemy获取动态 model名称 和 动态查询
需求 想要实现动态的查询,表名,字段,字段值都不是固定的 obj=表名.query.filter_by(字段=值1).first() obj.字段=值2 首先动态获取db_model名字(即Role) ...
- fastadmin model关联模型 关联查询问题
一对一关联 public function getGoodName(){ return $this->belongsTo('app\api\model\goods\Good','goods_go ...
- peewee基本使用
PEEWEE基本使用 Content Ⅰ 安装Ⅱ 链接数据库Ⅲ 建表 Ⅳ 增删改 Ⅴ 基础查询 Ⅵ ForeignKey Ⅷ 事务 参考官方文档:http://docs.peewee-o ...
- 3.orm之peewee
peewee是一款orm框架,为什么选择peewee,是因为它比较简单和Django比较类似,而且还有一个async-peewee,可以进行异步化. 如何定义model和生成表 ''' 我们要定义两张 ...
随机推荐
- 使用github和hexo搭建博客
title: How to build your blog by Hexo in github Welcome to huihuang's blog,you will find what you ex ...
- C#值类型参数传递的性能开销
Performance issues Let's dig a little deeper. When data is passed into methods as value type paramet ...
- css 常用代码解析
.cBan_1 .e2-pro li a{ display: block; -webkit-transition: all 0.3s linear;transition: all 0.3s linea ...
- php操作大文件
看了http://hi.baidu.com/qiaoyuetian/item/76c51f0ce25030e4f45ba69e(php读取大文件详解),然后测试了里边的代码,发现一些错误, 总结,红色 ...
- bootstrap和bootstrap-select的outline设置
.btn:focus, .btn:active:focus, .btn.active:focus, .btn.focus, .btn:active.focus, .btn.active.focus { ...
- 关于Xcode7更新之后使用 SDWebImage 图片加载不出来
解决方法:在Info.plist中添加NSAppTransportSecurity类型Dictionary. 在NSAppTransportSecurity下添加NSAllowsArbitraryLo ...
- R语言画图实例-参考R语言实战
dose <- c(, , , ,) drugA <- c(, , , , ) drugB <- c(, , , , ) # 数据准备 opar <- par(no.reado ...
- 【Junit】JUnit-4.12使用报java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing错误
下载了最新的JUnit版本,是4.12,结果尝试使用发现总是报java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing这样的错误, 上网查 ...
- R语言 奇怪的NA
> 1+NA [1] NA > NA==1 [1] NA > c(NA,1:50) [1] NA 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 ...
- Eclipse经常报Unhandled event loop exception的原因
在公司的电脑上,Eclipse经常报Unhandled event loop exception 错误,非常频繁,通过搜索发现是因为电脑上安装了百度杀毒导致的.... 无语 另外 teamviewer ...