在SQLAlchemy中使用OVER窗口功能 [英] Using the OVER window function in SQLAlchemy
本文介绍了在SQLAlchemy中使用OVER窗口功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用SQLAlchemy获得有限结果的总数。我目前正在使用Postgres,所以我知道我可以使用窗口函数。我基本上想知道如何在SQLAlchemy中编写以下内容:
How would I get the total count of a limited result with SQLAlchemy. I am currently using Postgres so I know I can use windowed functions. I basically want to know how I would write the following in SQLAlchemy:
SELECT foo
,count(*) OVER() AS full_count
FROM bar
ORDER BY <some col>
LIMIT <pagesize>
OFFSET <offset>
推荐答案
类似于:
select(
[
bar.c.foo,
func.count().over().label('full_count'),
],
...
)
引入此票证的票证: http://www.sqlalchemy.org/trac/票证/ 1844#comment:9
这篇关于在SQLAlchemy中使用OVER窗口功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文