MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / count

Method count

lib/sqlalchemy/ext/baked.py:409–421  ·  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

407 return result
408
409 def count(self):
410 """return the 'count'.
411
412 Equivalent to :meth:`_query.Query.count`.
413
414 Note this uses a subquery to ensure an accurate count regardless
415 of the structure of the original statement.
416
417 """
418
419 col = func.count(literal_column("*"))
420 bq = self.bq.with_criteria(lambda q: q._legacy_from_self(col))
421 return bq.for_session(self.session).params(self._params).scalar()
422
423 def scalar(self):
424 """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