Retrieving Scalar Values
You can retrieve scalar values by calling Query.scalar()
. For instance:
>>> PageView.select(fn.Count(fn.Distinct(PageView.url))).scalar()
100
You can retrieve multiple scalar values by passing as_tuple=True
:
>>> Employee.select(
... fn.Min(Employee.salary), fn.Max(Employee.salary)
... ).scalar(as_tuple=True)
(30000, 50000)