SQLAlchemy的group_by和order_by的区别

Posted 沧海一粟,何以久远

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了SQLAlchemy的group_by和order_by的区别相关的知识,希望对你有一定的参考价值。

1、官网解释:
group_by(*criterion)

apply one or more GROUP BY criterion to the query and return the newly resulting Query

功能:去重和排序

2、官网解释:

order_by(*criterion)

apply one or more ORDER BY criterion to the query and return the newly resulting Query

All existing ORDER BY settings can be suppressed by passing None - this will suppress any ORDER BY configured on mappers as well.

Alternatively, an existing ORDER BY setting on the Query object can be entirely cancelled by passing False as the value - use this before calling methods where an ORDER BY is invalid.

功能:只是排序,并不去重

参考:

1、http://docs.sqlalchemy.org/en/rel_0_9/orm/query.html

以上是关于SQLAlchemy的group_by和order_by的区别的主要内容,如果未能解决你的问题,请参考以下文章