时间:2021-07-01 10:21:17 帮助过:49人阅读
限制返回字段查询
person = session.query(Person.name, Person.created_at,
Person.updated_at).filter_by(name="zhongwei").order_by(
Person.created_at).first()
记录总数查询:
from sqlalchemy import func
# count User records, without
# using a subquery.
session.query(func.count(User.id))
# return count of user "id" grouped
# by "name"
session.query(func.count(User.id)). group_by(User.name)
from sqlalchemy import distinct
# count distinct "name" values
session.query(func.count(distinct(User.name)))
摘自:https://my.oschina.net/freegeek/blog/222725
几种常见sqlalchemy查询:
标签:param 子查询 values tool creat false ring title create