MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / count

Method count

lib/sqlalchemy/ext/baked.py:420–432  ·  view source on GitHub ↗

return the 'count'. Equivalent to :meth:`_query.Query.count`. Note this uses a subquery to ensure an accurate count regardless of the structure of the original statement.

(self)

Source from the content-addressed store, hash-verified

418 return result
419
420 def count(self):
421 """return the 'count'.
422
423 Equivalent to :meth:`_query.Query.count`.
424
425 Note this uses a subquery to ensure an accurate count regardless
426 of the structure of the original statement.
427
428 """
429
430 col = func.count(literal_column("*"))
431 bq = self.bq.with_criteria(lambda q: q._legacy_from_self(col))
432 return bq.for_session(self.session).params(self._params).scalar()
433
434 def scalar(self):
435 """Return the first element of the first result or None

Callers

nothing calls this directly

Calls 6

literal_columnFunction · 0.85
with_criteriaMethod · 0.80
_legacy_from_selfMethod · 0.80
for_sessionMethod · 0.80
scalarMethod · 0.45
paramsMethod · 0.45

Tested by

no test coverage detected