Retrieving Scalar Values

You can retrieve scalar values by calling Query.scalar(). For instance:

  1. >>> PageView.select(fn.Count(fn.Distinct(PageView.url))).scalar()
  2. 100

You can retrieve multiple scalar values by passing as_tuple=True:

  1. >>> Employee.select(
  2. ... fn.Min(Employee.salary), fn.Max(Employee.salary)
  3. ... ).scalar(as_tuple=True)
  4. (30000, 50000)