summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/engine
diff options
context:
space:
mode:
authormike bayer <mike_mp@zzzcomputing.com>2021-09-15 13:09:41 +0000
committerGerrit Code Review <gerrit@ci3.zzzcomputing.com>2021-09-15 13:09:41 +0000
commit62c7ea80a905d839d279f0ccb8c7c3626e1313be (patch)
treed76848daaf6fb317922b270a2d7d3c2da535c670 /lib/sqlalchemy/engine
parent990eb3d8813369d3b8a7776ae85fb33627443d30 (diff)
parent4127482cc5edff8967b991bfc9398c47ce6e8a83 (diff)
downloadsqlalchemy-62c7ea80a905d839d279f0ccb8c7c3626e1313be.tar.gz
Merge "Add scalars method to connection and session classes"
Diffstat (limited to 'lib/sqlalchemy/engine')
-rw-r--r--lib/sqlalchemy/engine/base.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/sqlalchemy/engine/base.py b/lib/sqlalchemy/engine/base.py
index a316f904f..25ced0343 100644
--- a/lib/sqlalchemy/engine/base.py
+++ b/lib/sqlalchemy/engine/base.py
@@ -1157,10 +1157,28 @@ class Connection(Connectable):
"""Executes and returns the first column of the first row.
The underlying result/cursor is closed after execution.
+
"""
return self.execute(object_, *multiparams, **params).scalar()
+ def scalars(self, object_, *multiparams, **params):
+ """Executes and returns a scalar result set, which yields scalar values
+ from the first column of each row.
+
+ This method is equivalent to calling :meth:`_engine.Connection.execute`
+ to receive a :class:`_result.Result` object, then invoking the
+ :meth:`_result.Result.scalars` method to produce a
+ :class:`_result.ScalarResult` instance.
+
+ :return: a :class:`_result.ScalarResult`
+
+ .. versionadded:: 1.4.24
+
+ """
+
+ return self.execute(object_, *multiparams, **params).scalars()
+
def execute(self, statement, *multiparams, **params):
r"""Executes a SQL statement construct and returns a
:class:`_engine.CursorResult`.