SQLAlchemy 2.1.0b2__cp313-cp313t-win_arm64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (270) hide show
  1. sqlalchemy/__init__.py +298 -0
  2. sqlalchemy/connectors/__init__.py +18 -0
  3. sqlalchemy/connectors/aioodbc.py +171 -0
  4. sqlalchemy/connectors/asyncio.py +476 -0
  5. sqlalchemy/connectors/pyodbc.py +250 -0
  6. sqlalchemy/dialects/__init__.py +62 -0
  7. sqlalchemy/dialects/_typing.py +30 -0
  8. sqlalchemy/dialects/mssql/__init__.py +89 -0
  9. sqlalchemy/dialects/mssql/aioodbc.py +63 -0
  10. sqlalchemy/dialects/mssql/base.py +4166 -0
  11. sqlalchemy/dialects/mssql/information_schema.py +285 -0
  12. sqlalchemy/dialects/mssql/json.py +140 -0
  13. sqlalchemy/dialects/mssql/mssqlpython.py +220 -0
  14. sqlalchemy/dialects/mssql/provision.py +196 -0
  15. sqlalchemy/dialects/mssql/pymssql.py +126 -0
  16. sqlalchemy/dialects/mssql/pyodbc.py +698 -0
  17. sqlalchemy/dialects/mysql/__init__.py +106 -0
  18. sqlalchemy/dialects/mysql/_mariadb_shim.py +312 -0
  19. sqlalchemy/dialects/mysql/aiomysql.py +226 -0
  20. sqlalchemy/dialects/mysql/asyncmy.py +214 -0
  21. sqlalchemy/dialects/mysql/base.py +3877 -0
  22. sqlalchemy/dialects/mysql/cymysql.py +106 -0
  23. sqlalchemy/dialects/mysql/dml.py +279 -0
  24. sqlalchemy/dialects/mysql/enumerated.py +277 -0
  25. sqlalchemy/dialects/mysql/expression.py +146 -0
  26. sqlalchemy/dialects/mysql/json.py +92 -0
  27. sqlalchemy/dialects/mysql/mariadb.py +67 -0
  28. sqlalchemy/dialects/mysql/mariadbconnector.py +330 -0
  29. sqlalchemy/dialects/mysql/mysqlconnector.py +296 -0
  30. sqlalchemy/dialects/mysql/mysqldb.py +312 -0
  31. sqlalchemy/dialects/mysql/provision.py +153 -0
  32. sqlalchemy/dialects/mysql/pymysql.py +157 -0
  33. sqlalchemy/dialects/mysql/pyodbc.py +156 -0
  34. sqlalchemy/dialects/mysql/reflection.py +724 -0
  35. sqlalchemy/dialects/mysql/reserved_words.py +570 -0
  36. sqlalchemy/dialects/mysql/types.py +845 -0
  37. sqlalchemy/dialects/oracle/__init__.py +85 -0
  38. sqlalchemy/dialects/oracle/base.py +3977 -0
  39. sqlalchemy/dialects/oracle/cx_oracle.py +1601 -0
  40. sqlalchemy/dialects/oracle/dictionary.py +507 -0
  41. sqlalchemy/dialects/oracle/json.py +158 -0
  42. sqlalchemy/dialects/oracle/oracledb.py +909 -0
  43. sqlalchemy/dialects/oracle/provision.py +288 -0
  44. sqlalchemy/dialects/oracle/types.py +367 -0
  45. sqlalchemy/dialects/oracle/vector.py +368 -0
  46. sqlalchemy/dialects/postgresql/__init__.py +171 -0
  47. sqlalchemy/dialects/postgresql/_psycopg_common.py +229 -0
  48. sqlalchemy/dialects/postgresql/array.py +534 -0
  49. sqlalchemy/dialects/postgresql/asyncpg.py +1323 -0
  50. sqlalchemy/dialects/postgresql/base.py +5789 -0
  51. sqlalchemy/dialects/postgresql/bitstring.py +327 -0
  52. sqlalchemy/dialects/postgresql/dml.py +360 -0
  53. sqlalchemy/dialects/postgresql/ext.py +593 -0
  54. sqlalchemy/dialects/postgresql/hstore.py +423 -0
  55. sqlalchemy/dialects/postgresql/json.py +408 -0
  56. sqlalchemy/dialects/postgresql/named_types.py +521 -0
  57. sqlalchemy/dialects/postgresql/operators.py +130 -0
  58. sqlalchemy/dialects/postgresql/pg8000.py +670 -0
  59. sqlalchemy/dialects/postgresql/pg_catalog.py +344 -0
  60. sqlalchemy/dialects/postgresql/provision.py +184 -0
  61. sqlalchemy/dialects/postgresql/psycopg.py +799 -0
  62. sqlalchemy/dialects/postgresql/psycopg2.py +860 -0
  63. sqlalchemy/dialects/postgresql/psycopg2cffi.py +61 -0
  64. sqlalchemy/dialects/postgresql/ranges.py +1002 -0
  65. sqlalchemy/dialects/postgresql/types.py +388 -0
  66. sqlalchemy/dialects/sqlite/__init__.py +57 -0
  67. sqlalchemy/dialects/sqlite/aiosqlite.py +321 -0
  68. sqlalchemy/dialects/sqlite/base.py +3063 -0
  69. sqlalchemy/dialects/sqlite/dml.py +279 -0
  70. sqlalchemy/dialects/sqlite/json.py +100 -0
  71. sqlalchemy/dialects/sqlite/provision.py +229 -0
  72. sqlalchemy/dialects/sqlite/pysqlcipher.py +161 -0
  73. sqlalchemy/dialects/sqlite/pysqlite.py +754 -0
  74. sqlalchemy/dialects/type_migration_guidelines.txt +145 -0
  75. sqlalchemy/engine/__init__.py +62 -0
  76. sqlalchemy/engine/_processors_cy.cp313t-win_arm64.pyd +0 -0
  77. sqlalchemy/engine/_processors_cy.py +92 -0
  78. sqlalchemy/engine/_result_cy.cp313t-win_arm64.pyd +0 -0
  79. sqlalchemy/engine/_result_cy.py +633 -0
  80. sqlalchemy/engine/_row_cy.cp313t-win_arm64.pyd +0 -0
  81. sqlalchemy/engine/_row_cy.py +232 -0
  82. sqlalchemy/engine/_util_cy.cp313t-win_arm64.pyd +0 -0
  83. sqlalchemy/engine/_util_cy.py +136 -0
  84. sqlalchemy/engine/base.py +3354 -0
  85. sqlalchemy/engine/characteristics.py +155 -0
  86. sqlalchemy/engine/create.py +877 -0
  87. sqlalchemy/engine/cursor.py +2421 -0
  88. sqlalchemy/engine/default.py +2402 -0
  89. sqlalchemy/engine/events.py +965 -0
  90. sqlalchemy/engine/interfaces.py +3495 -0
  91. sqlalchemy/engine/mock.py +134 -0
  92. sqlalchemy/engine/processors.py +82 -0
  93. sqlalchemy/engine/reflection.py +2100 -0
  94. sqlalchemy/engine/result.py +1966 -0
  95. sqlalchemy/engine/row.py +397 -0
  96. sqlalchemy/engine/strategies.py +16 -0
  97. sqlalchemy/engine/url.py +922 -0
  98. sqlalchemy/engine/util.py +156 -0
  99. sqlalchemy/event/__init__.py +26 -0
  100. sqlalchemy/event/api.py +220 -0
  101. sqlalchemy/event/attr.py +674 -0
  102. sqlalchemy/event/base.py +472 -0
  103. sqlalchemy/event/legacy.py +258 -0
  104. sqlalchemy/event/registry.py +390 -0
  105. sqlalchemy/events.py +17 -0
  106. sqlalchemy/exc.py +922 -0
  107. sqlalchemy/ext/__init__.py +11 -0
  108. sqlalchemy/ext/associationproxy.py +2072 -0
  109. sqlalchemy/ext/asyncio/__init__.py +29 -0
  110. sqlalchemy/ext/asyncio/base.py +281 -0
  111. sqlalchemy/ext/asyncio/engine.py +1487 -0
  112. sqlalchemy/ext/asyncio/exc.py +21 -0
  113. sqlalchemy/ext/asyncio/result.py +994 -0
  114. sqlalchemy/ext/asyncio/scoping.py +1679 -0
  115. sqlalchemy/ext/asyncio/session.py +2007 -0
  116. sqlalchemy/ext/automap.py +1701 -0
  117. sqlalchemy/ext/baked.py +559 -0
  118. sqlalchemy/ext/compiler.py +600 -0
  119. sqlalchemy/ext/declarative/__init__.py +65 -0
  120. sqlalchemy/ext/declarative/extensions.py +560 -0
  121. sqlalchemy/ext/horizontal_shard.py +481 -0
  122. sqlalchemy/ext/hybrid.py +1877 -0
  123. sqlalchemy/ext/indexable.py +364 -0
  124. sqlalchemy/ext/instrumentation.py +450 -0
  125. sqlalchemy/ext/mutable.py +1081 -0
  126. sqlalchemy/ext/orderinglist.py +439 -0
  127. sqlalchemy/ext/serializer.py +185 -0
  128. sqlalchemy/future/__init__.py +16 -0
  129. sqlalchemy/future/engine.py +15 -0
  130. sqlalchemy/inspection.py +174 -0
  131. sqlalchemy/log.py +283 -0
  132. sqlalchemy/orm/__init__.py +176 -0
  133. sqlalchemy/orm/_orm_constructors.py +2694 -0
  134. sqlalchemy/orm/_typing.py +179 -0
  135. sqlalchemy/orm/attributes.py +2868 -0
  136. sqlalchemy/orm/base.py +976 -0
  137. sqlalchemy/orm/bulk_persistence.py +2152 -0
  138. sqlalchemy/orm/clsregistry.py +582 -0
  139. sqlalchemy/orm/collections.py +1568 -0
  140. sqlalchemy/orm/context.py +3471 -0
  141. sqlalchemy/orm/decl_api.py +2280 -0
  142. sqlalchemy/orm/decl_base.py +2309 -0
  143. sqlalchemy/orm/dependency.py +1306 -0
  144. sqlalchemy/orm/descriptor_props.py +1183 -0
  145. sqlalchemy/orm/dynamic.py +307 -0
  146. sqlalchemy/orm/evaluator.py +379 -0
  147. sqlalchemy/orm/events.py +3386 -0
  148. sqlalchemy/orm/exc.py +237 -0
  149. sqlalchemy/orm/identity.py +302 -0
  150. sqlalchemy/orm/instrumentation.py +746 -0
  151. sqlalchemy/orm/interfaces.py +1589 -0
  152. sqlalchemy/orm/loading.py +1684 -0
  153. sqlalchemy/orm/mapped_collection.py +557 -0
  154. sqlalchemy/orm/mapper.py +4411 -0
  155. sqlalchemy/orm/path_registry.py +829 -0
  156. sqlalchemy/orm/persistence.py +1789 -0
  157. sqlalchemy/orm/properties.py +973 -0
  158. sqlalchemy/orm/query.py +3528 -0
  159. sqlalchemy/orm/relationships.py +3570 -0
  160. sqlalchemy/orm/scoping.py +2232 -0
  161. sqlalchemy/orm/session.py +5403 -0
  162. sqlalchemy/orm/state.py +1175 -0
  163. sqlalchemy/orm/state_changes.py +196 -0
  164. sqlalchemy/orm/strategies.py +3492 -0
  165. sqlalchemy/orm/strategy_options.py +2562 -0
  166. sqlalchemy/orm/sync.py +164 -0
  167. sqlalchemy/orm/unitofwork.py +798 -0
  168. sqlalchemy/orm/util.py +2438 -0
  169. sqlalchemy/orm/writeonly.py +694 -0
  170. sqlalchemy/pool/__init__.py +41 -0
  171. sqlalchemy/pool/base.py +1522 -0
  172. sqlalchemy/pool/events.py +375 -0
  173. sqlalchemy/pool/impl.py +582 -0
  174. sqlalchemy/py.typed +0 -0
  175. sqlalchemy/schema.py +74 -0
  176. sqlalchemy/sql/__init__.py +156 -0
  177. sqlalchemy/sql/_annotated_cols.py +397 -0
  178. sqlalchemy/sql/_dml_constructors.py +132 -0
  179. sqlalchemy/sql/_elements_constructors.py +2164 -0
  180. sqlalchemy/sql/_orm_types.py +20 -0
  181. sqlalchemy/sql/_selectable_constructors.py +840 -0
  182. sqlalchemy/sql/_typing.py +487 -0
  183. sqlalchemy/sql/_util_cy.cp313t-win_arm64.pyd +0 -0
  184. sqlalchemy/sql/_util_cy.py +127 -0
  185. sqlalchemy/sql/annotation.py +590 -0
  186. sqlalchemy/sql/base.py +2699 -0
  187. sqlalchemy/sql/cache_key.py +1066 -0
  188. sqlalchemy/sql/coercions.py +1373 -0
  189. sqlalchemy/sql/compiler.py +8327 -0
  190. sqlalchemy/sql/crud.py +1815 -0
  191. sqlalchemy/sql/ddl.py +1928 -0
  192. sqlalchemy/sql/default_comparator.py +654 -0
  193. sqlalchemy/sql/dml.py +1977 -0
  194. sqlalchemy/sql/elements.py +6033 -0
  195. sqlalchemy/sql/events.py +458 -0
  196. sqlalchemy/sql/expression.py +172 -0
  197. sqlalchemy/sql/functions.py +2305 -0
  198. sqlalchemy/sql/lambdas.py +1443 -0
  199. sqlalchemy/sql/naming.py +209 -0
  200. sqlalchemy/sql/operators.py +2897 -0
  201. sqlalchemy/sql/roles.py +332 -0
  202. sqlalchemy/sql/schema.py +6703 -0
  203. sqlalchemy/sql/selectable.py +7553 -0
  204. sqlalchemy/sql/sqltypes.py +4093 -0
  205. sqlalchemy/sql/traversals.py +1042 -0
  206. sqlalchemy/sql/type_api.py +2446 -0
  207. sqlalchemy/sql/util.py +1495 -0
  208. sqlalchemy/sql/visitors.py +1157 -0
  209. sqlalchemy/testing/__init__.py +96 -0
  210. sqlalchemy/testing/assertions.py +1007 -0
  211. sqlalchemy/testing/assertsql.py +519 -0
  212. sqlalchemy/testing/asyncio.py +128 -0
  213. sqlalchemy/testing/config.py +440 -0
  214. sqlalchemy/testing/engines.py +483 -0
  215. sqlalchemy/testing/entities.py +117 -0
  216. sqlalchemy/testing/exclusions.py +476 -0
  217. sqlalchemy/testing/fixtures/__init__.py +30 -0
  218. sqlalchemy/testing/fixtures/base.py +384 -0
  219. sqlalchemy/testing/fixtures/mypy.py +247 -0
  220. sqlalchemy/testing/fixtures/orm.py +227 -0
  221. sqlalchemy/testing/fixtures/sql.py +538 -0
  222. sqlalchemy/testing/pickleable.py +155 -0
  223. sqlalchemy/testing/plugin/__init__.py +6 -0
  224. sqlalchemy/testing/plugin/bootstrap.py +51 -0
  225. sqlalchemy/testing/plugin/plugin_base.py +828 -0
  226. sqlalchemy/testing/plugin/pytestplugin.py +892 -0
  227. sqlalchemy/testing/profiling.py +329 -0
  228. sqlalchemy/testing/provision.py +613 -0
  229. sqlalchemy/testing/requirements.py +1978 -0
  230. sqlalchemy/testing/schema.py +198 -0
  231. sqlalchemy/testing/suite/__init__.py +19 -0
  232. sqlalchemy/testing/suite/test_cte.py +237 -0
  233. sqlalchemy/testing/suite/test_ddl.py +420 -0
  234. sqlalchemy/testing/suite/test_dialect.py +776 -0
  235. sqlalchemy/testing/suite/test_insert.py +630 -0
  236. sqlalchemy/testing/suite/test_reflection.py +3557 -0
  237. sqlalchemy/testing/suite/test_results.py +660 -0
  238. sqlalchemy/testing/suite/test_rowcount.py +258 -0
  239. sqlalchemy/testing/suite/test_select.py +2112 -0
  240. sqlalchemy/testing/suite/test_sequence.py +317 -0
  241. sqlalchemy/testing/suite/test_table_via_select.py +686 -0
  242. sqlalchemy/testing/suite/test_types.py +2271 -0
  243. sqlalchemy/testing/suite/test_unicode_ddl.py +189 -0
  244. sqlalchemy/testing/suite/test_update_delete.py +139 -0
  245. sqlalchemy/testing/util.py +535 -0
  246. sqlalchemy/testing/warnings.py +52 -0
  247. sqlalchemy/types.py +76 -0
  248. sqlalchemy/util/__init__.py +158 -0
  249. sqlalchemy/util/_collections.py +688 -0
  250. sqlalchemy/util/_collections_cy.cp313t-win_arm64.pyd +0 -0
  251. sqlalchemy/util/_collections_cy.pxd +8 -0
  252. sqlalchemy/util/_collections_cy.py +516 -0
  253. sqlalchemy/util/_has_cython.py +46 -0
  254. sqlalchemy/util/_immutabledict_cy.cp313t-win_arm64.pyd +0 -0
  255. sqlalchemy/util/_immutabledict_cy.py +240 -0
  256. sqlalchemy/util/compat.py +299 -0
  257. sqlalchemy/util/concurrency.py +322 -0
  258. sqlalchemy/util/cython.py +79 -0
  259. sqlalchemy/util/deprecations.py +401 -0
  260. sqlalchemy/util/langhelpers.py +2320 -0
  261. sqlalchemy/util/preloaded.py +152 -0
  262. sqlalchemy/util/queue.py +304 -0
  263. sqlalchemy/util/tool_support.py +201 -0
  264. sqlalchemy/util/topological.py +120 -0
  265. sqlalchemy/util/typing.py +711 -0
  266. sqlalchemy-2.1.0b2.dist-info/METADATA +269 -0
  267. sqlalchemy-2.1.0b2.dist-info/RECORD +270 -0
  268. sqlalchemy-2.1.0b2.dist-info/WHEEL +5 -0
  269. sqlalchemy-2.1.0b2.dist-info/licenses/LICENSE +19 -0
  270. sqlalchemy-2.1.0b2.dist-info/top_level.txt +1 -0
@@ -0,0 +1,994 @@
1
+ # ext/asyncio/result.py
2
+ # Copyright (C) 2020-2026 the SQLAlchemy authors and contributors
3
+ # <see AUTHORS file>
4
+ #
5
+ # This module is part of SQLAlchemy and is released under
6
+ # the MIT License: https://www.opensource.org/licenses/mit-license.php
7
+ from __future__ import annotations
8
+
9
+ import operator
10
+ from typing import Any
11
+ from typing import AsyncIterator
12
+ from typing import Literal
13
+ from typing import Optional
14
+ from typing import overload
15
+ from typing import Sequence
16
+ from typing import Tuple
17
+ from typing import TYPE_CHECKING
18
+ from typing import TypeVar
19
+
20
+ from . import exc as async_exc
21
+ from ... import util
22
+ from ...engine import Result
23
+ from ...engine.result import _NO_ROW
24
+ from ...engine.result import _R
25
+ from ...engine.result import _WithKeys
26
+ from ...engine.result import FilterResult
27
+ from ...engine.result import FrozenResult
28
+ from ...engine.result import ResultMetaData
29
+ from ...engine.row import Row
30
+ from ...engine.row import RowMapping
31
+ from ...sql.base import _generative
32
+ from ...util import deprecated
33
+ from ...util.concurrency import greenlet_spawn
34
+ from ...util.typing import Self
35
+ from ...util.typing import TupleAny
36
+ from ...util.typing import TypeVarTuple
37
+ from ...util.typing import Unpack
38
+
39
+ if TYPE_CHECKING:
40
+ from ...engine import CursorResult
41
+ from ...engine.result import _KeyIndexType
42
+ from ...engine.result import _UniqueFilterType
43
+
44
+ _T = TypeVar("_T", bound=Any)
45
+ _Ts = TypeVarTuple("_Ts")
46
+
47
+
48
+ class AsyncCommon(FilterResult[_R]):
49
+ __slots__ = ()
50
+
51
+ _real_result: Result[Unpack[TupleAny]]
52
+ _metadata: ResultMetaData
53
+
54
+ async def close(self) -> None: # type: ignore[override]
55
+ """Close this result."""
56
+
57
+ await greenlet_spawn(self._real_result.close)
58
+
59
+ @property
60
+ def closed(self) -> bool:
61
+ """proxies the .closed attribute of the underlying result object,
62
+ if any, else raises ``AttributeError``.
63
+
64
+ .. versionadded:: 2.0.0b3
65
+
66
+ """
67
+ return self._real_result.closed
68
+
69
+
70
+ class AsyncResult(_WithKeys, AsyncCommon[Row[Unpack[_Ts]]]):
71
+ """An asyncio wrapper around a :class:`_result.Result` object.
72
+
73
+ The :class:`_asyncio.AsyncResult` only applies to statement executions that
74
+ use a server-side cursor. It is returned only from the
75
+ :meth:`_asyncio.AsyncConnection.stream` and
76
+ :meth:`_asyncio.AsyncSession.stream` methods.
77
+
78
+ .. note:: As is the case with :class:`_engine.Result`, this object is
79
+ used for ORM results returned by :meth:`_asyncio.AsyncSession.execute`,
80
+ which can yield instances of ORM mapped objects either individually or
81
+ within tuple-like rows. Note that these result objects do not
82
+ deduplicate instances or rows automatically as is the case with the
83
+ legacy :class:`_orm.Query` object. For in-Python de-duplication of
84
+ instances or rows, use the :meth:`_asyncio.AsyncResult.unique` modifier
85
+ method.
86
+
87
+ .. versionadded:: 1.4
88
+
89
+ """
90
+
91
+ __slots__ = ()
92
+
93
+ _real_result: Result[Unpack[_Ts]]
94
+
95
+ def __init__(self, real_result: Result[Unpack[_Ts]]):
96
+ self._real_result = real_result
97
+
98
+ self._metadata = real_result._metadata
99
+ self._unique_filter_state = real_result._unique_filter_state
100
+ self._source_supports_scalars = real_result._source_supports_scalars
101
+ self._post_creational_filter = None
102
+
103
+ # BaseCursorResult pre-generates the "_row_getter". Use that
104
+ # if available rather than building a second one
105
+ if "_row_getter" in real_result.__dict__:
106
+ self._set_memoized_attribute(
107
+ "_row_getter", real_result.__dict__["_row_getter"]
108
+ )
109
+
110
+ @property
111
+ @deprecated(
112
+ "2.1.0",
113
+ "The :attr:`.AsyncResult.t` attribute is deprecated, :class:`.Row` "
114
+ "now behaves like a tuple and can unpack types directly.",
115
+ )
116
+ def t(self) -> AsyncTupleResult[Tuple[Unpack[_Ts]]]:
117
+ """Apply a "typed tuple" typing filter to returned rows.
118
+
119
+ The :attr:`_asyncio.AsyncResult.t` attribute is a synonym for
120
+ calling the :meth:`_asyncio.AsyncResult.tuples` method.
121
+
122
+ .. versionadded:: 2.0
123
+
124
+ .. seealso::
125
+
126
+ :ref:`change_10635` - describes a migration path from this
127
+ workaround for SQLAlchemy 2.1.
128
+
129
+ """
130
+ return self # type: ignore
131
+
132
+ @deprecated(
133
+ "2.1.0",
134
+ "The :meth:`.AsyncResult.tuples` method is deprecated, "
135
+ ":class:`.Row` now behaves like a tuple and can unpack types "
136
+ "directly.",
137
+ )
138
+ def tuples(self) -> AsyncTupleResult[Tuple[Unpack[_Ts]]]:
139
+ """Apply a "typed tuple" typing filter to returned rows.
140
+
141
+ This method returns the same :class:`_asyncio.AsyncResult` object
142
+ at runtime,
143
+ however annotates as returning a :class:`_asyncio.AsyncTupleResult`
144
+ object that will indicate to :pep:`484` typing tools that plain typed
145
+ ``Tuple`` instances are returned rather than rows. This allows
146
+ tuple unpacking and ``__getitem__`` access of :class:`_engine.Row`
147
+ objects to by typed, for those cases where the statement invoked
148
+ itself included typing information.
149
+
150
+ .. versionadded:: 2.0
151
+
152
+ :return: the :class:`_result.AsyncTupleResult` type at typing time.
153
+
154
+ .. seealso::
155
+
156
+ :ref:`change_10635` - describes a migration path from this
157
+ workaround for SQLAlchemy 2.1.
158
+
159
+ :attr:`_asyncio.AsyncResult.t` - shorter synonym
160
+
161
+ :attr:`_engine.Row.t` - :class:`_engine.Row` version
162
+
163
+ """
164
+
165
+ return self # type: ignore
166
+
167
+ @_generative
168
+ def unique(self, strategy: Optional[_UniqueFilterType] = None) -> Self:
169
+ """Apply unique filtering to the objects returned by this
170
+ :class:`_asyncio.AsyncResult`.
171
+
172
+ Refer to :meth:`_engine.Result.unique` in the synchronous
173
+ SQLAlchemy API for a complete behavioral description.
174
+
175
+ """
176
+ self._unique_filter_state = (set(), strategy)
177
+ return self
178
+
179
+ def columns(self, *col_expressions: _KeyIndexType) -> Self:
180
+ r"""Establish the columns that should be returned in each row.
181
+
182
+ Refer to :meth:`_engine.Result.columns` in the synchronous
183
+ SQLAlchemy API for a complete behavioral description.
184
+
185
+ """
186
+ return self._column_slices(col_expressions)
187
+
188
+ async def partitions(
189
+ self, size: Optional[int] = None
190
+ ) -> AsyncIterator[Sequence[Row[Unpack[_Ts]]]]:
191
+ """Iterate through sub-lists of rows of the size given.
192
+
193
+ An async iterator is returned::
194
+
195
+ async def scroll_results(connection):
196
+ result = await connection.stream(select(users_table))
197
+
198
+ async for partition in result.partitions(100):
199
+ print("list of rows: %s" % partition)
200
+
201
+ Refer to :meth:`_engine.Result.partitions` in the synchronous
202
+ SQLAlchemy API for a complete behavioral description.
203
+
204
+ """
205
+
206
+ getter = self._manyrow_getter
207
+
208
+ while True:
209
+ partition = await greenlet_spawn(getter, self, size)
210
+ if partition:
211
+ yield partition
212
+ else:
213
+ break
214
+
215
+ async def fetchall(self) -> Sequence[Row[Unpack[_Ts]]]:
216
+ """A synonym for the :meth:`_asyncio.AsyncResult.all` method.
217
+
218
+ .. versionadded:: 2.0
219
+
220
+ """
221
+
222
+ return await greenlet_spawn(self._allrows)
223
+
224
+ async def fetchone(self) -> Optional[Row[Unpack[_Ts]]]:
225
+ """Fetch one row.
226
+
227
+ When all rows are exhausted, returns None.
228
+
229
+ This method is provided for backwards compatibility with
230
+ SQLAlchemy 1.x.x.
231
+
232
+ To fetch the first row of a result only, use the
233
+ :meth:`_asyncio.AsyncResult.first` method. To iterate through all
234
+ rows, iterate the :class:`_asyncio.AsyncResult` object directly.
235
+
236
+ :return: a :class:`_engine.Row` object if no filters are applied,
237
+ or ``None`` if no rows remain.
238
+
239
+ """
240
+ row = await greenlet_spawn(self._onerow_getter, self)
241
+ if row is _NO_ROW:
242
+ return None
243
+ else:
244
+ return row
245
+
246
+ async def fetchmany(
247
+ self, size: Optional[int] = None
248
+ ) -> Sequence[Row[Unpack[_Ts]]]:
249
+ """Fetch many rows.
250
+
251
+ When all rows are exhausted, returns an empty list.
252
+
253
+ This method is provided for backwards compatibility with
254
+ SQLAlchemy 1.x.x.
255
+
256
+ To fetch rows in groups, use the
257
+ :meth:`._asyncio.AsyncResult.partitions` method.
258
+
259
+ :return: a list of :class:`_engine.Row` objects.
260
+
261
+ .. seealso::
262
+
263
+ :meth:`_asyncio.AsyncResult.partitions`
264
+
265
+ """
266
+
267
+ return await greenlet_spawn(self._manyrow_getter, self, size)
268
+
269
+ async def all(self) -> Sequence[Row[Unpack[_Ts]]]:
270
+ """Return all rows in a list.
271
+
272
+ Closes the result set after invocation. Subsequent invocations
273
+ will return an empty list.
274
+
275
+ :return: a list of :class:`_engine.Row` objects.
276
+
277
+ """
278
+
279
+ return await greenlet_spawn(self._allrows)
280
+
281
+ def __aiter__(self) -> AsyncResult[Unpack[_Ts]]:
282
+ return self
283
+
284
+ async def __anext__(self) -> Row[Unpack[_Ts]]:
285
+ row = await greenlet_spawn(self._onerow_getter, self)
286
+ if row is _NO_ROW:
287
+ raise StopAsyncIteration()
288
+ else:
289
+ return row
290
+
291
+ async def first(self) -> Optional[Row[Unpack[_Ts]]]:
292
+ """Fetch the first row or ``None`` if no row is present.
293
+
294
+ Closes the result set and discards remaining rows.
295
+
296
+ .. note:: This method returns one **row**, e.g. tuple, by default.
297
+ To return exactly one single scalar value, that is, the first
298
+ column of the first row, use the
299
+ :meth:`_asyncio.AsyncResult.scalar` method,
300
+ or combine :meth:`_asyncio.AsyncResult.scalars` and
301
+ :meth:`_asyncio.AsyncResult.first`.
302
+
303
+ Additionally, in contrast to the behavior of the legacy ORM
304
+ :meth:`_orm.Query.first` method, **no limit is applied** to the
305
+ SQL query which was invoked to produce this
306
+ :class:`_asyncio.AsyncResult`;
307
+ for a DBAPI driver that buffers results in memory before yielding
308
+ rows, all rows will be sent to the Python process and all but
309
+ the first row will be discarded.
310
+
311
+ .. seealso::
312
+
313
+ :ref:`migration_20_unify_select`
314
+
315
+ :return: a :class:`_engine.Row` object, or None
316
+ if no rows remain.
317
+
318
+ .. seealso::
319
+
320
+ :meth:`_asyncio.AsyncResult.scalar`
321
+
322
+ :meth:`_asyncio.AsyncResult.one`
323
+
324
+ """
325
+ return await greenlet_spawn(self._only_one_row, False, False, False)
326
+
327
+ async def one_or_none(self) -> Optional[Row[Unpack[_Ts]]]:
328
+ """Return at most one result or raise an exception.
329
+
330
+ Returns ``None`` if the result has no rows.
331
+ Raises :class:`.MultipleResultsFound`
332
+ if multiple rows are returned.
333
+
334
+ .. versionadded:: 1.4
335
+
336
+ :return: The first :class:`_engine.Row` or ``None`` if no row
337
+ is available.
338
+
339
+ :raises: :class:`.MultipleResultsFound`
340
+
341
+ .. seealso::
342
+
343
+ :meth:`_asyncio.AsyncResult.first`
344
+
345
+ :meth:`_asyncio.AsyncResult.one`
346
+
347
+ """
348
+ return await greenlet_spawn(self._only_one_row, True, False, False)
349
+
350
+ @overload
351
+ async def scalar_one(self: AsyncResult[_T]) -> _T: ...
352
+
353
+ @overload
354
+ async def scalar_one(self) -> Any: ...
355
+
356
+ async def scalar_one(self) -> Any:
357
+ """Return exactly one scalar result or raise an exception.
358
+
359
+ This is equivalent to calling :meth:`_asyncio.AsyncResult.scalars` and
360
+ then :meth:`_asyncio.AsyncScalarResult.one`.
361
+
362
+ .. seealso::
363
+
364
+ :meth:`_asyncio.AsyncScalarResult.one`
365
+
366
+ :meth:`_asyncio.AsyncResult.scalars`
367
+
368
+ """
369
+ return await greenlet_spawn(self._only_one_row, True, True, True)
370
+
371
+ @overload
372
+ async def scalar_one_or_none(
373
+ self: AsyncResult[_T],
374
+ ) -> Optional[_T]: ...
375
+
376
+ @overload
377
+ async def scalar_one_or_none(self) -> Optional[Any]: ...
378
+
379
+ async def scalar_one_or_none(self) -> Optional[Any]:
380
+ """Return exactly one scalar result or ``None``.
381
+
382
+ This is equivalent to calling :meth:`_asyncio.AsyncResult.scalars` and
383
+ then :meth:`_asyncio.AsyncScalarResult.one_or_none`.
384
+
385
+ .. seealso::
386
+
387
+ :meth:`_asyncio.AsyncScalarResult.one_or_none`
388
+
389
+ :meth:`_asyncio.AsyncResult.scalars`
390
+
391
+ """
392
+ return await greenlet_spawn(self._only_one_row, True, False, True)
393
+
394
+ async def one(self) -> Row[Unpack[_Ts]]:
395
+ """Return exactly one row or raise an exception.
396
+
397
+ Raises :class:`.NoResultFound` if the result returns no
398
+ rows, or :class:`.MultipleResultsFound` if multiple rows
399
+ would be returned.
400
+
401
+ .. note:: This method returns one **row**, e.g. tuple, by default.
402
+ To return exactly one single scalar value, that is, the first
403
+ column of the first row, use the
404
+ :meth:`_asyncio.AsyncResult.scalar_one` method, or combine
405
+ :meth:`_asyncio.AsyncResult.scalars` and
406
+ :meth:`_asyncio.AsyncResult.one`.
407
+
408
+ .. versionadded:: 1.4
409
+
410
+ :return: The first :class:`_engine.Row`.
411
+
412
+ :raises: :class:`.MultipleResultsFound`, :class:`.NoResultFound`
413
+
414
+ .. seealso::
415
+
416
+ :meth:`_asyncio.AsyncResult.first`
417
+
418
+ :meth:`_asyncio.AsyncResult.one_or_none`
419
+
420
+ :meth:`_asyncio.AsyncResult.scalar_one`
421
+
422
+ """
423
+ return await greenlet_spawn(self._only_one_row, True, True, False)
424
+
425
+ @overload
426
+ async def scalar(self: AsyncResult[_T]) -> Optional[_T]: ...
427
+
428
+ @overload
429
+ async def scalar(self) -> Any: ...
430
+
431
+ async def scalar(self) -> Any:
432
+ """Fetch the first column of the first row, and close the result set.
433
+
434
+ Returns ``None`` if there are no rows to fetch.
435
+
436
+ No validation is performed to test if additional rows remain.
437
+
438
+ After calling this method, the object is fully closed,
439
+ e.g. the :meth:`_engine.CursorResult.close`
440
+ method will have been called.
441
+
442
+ :return: a Python scalar value, or ``None`` if no rows remain.
443
+
444
+ """
445
+ return await greenlet_spawn(self._only_one_row, False, False, True)
446
+
447
+ async def freeze(self) -> FrozenResult[Unpack[_Ts]]:
448
+ """Return a callable object that will produce copies of this
449
+ :class:`_asyncio.AsyncResult` when invoked.
450
+
451
+ The callable object returned is an instance of
452
+ :class:`_engine.FrozenResult`.
453
+
454
+ This is used for result set caching. The method must be called
455
+ on the result when it has been unconsumed, and calling the method
456
+ will consume the result fully. When the :class:`_engine.FrozenResult`
457
+ is retrieved from a cache, it can be called any number of times where
458
+ it will produce a new :class:`_engine.Result` object each time
459
+ against its stored set of rows.
460
+
461
+ .. seealso::
462
+
463
+ :ref:`do_orm_execute_re_executing` - example usage within the
464
+ ORM to implement a result-set cache.
465
+
466
+ """
467
+
468
+ return await greenlet_spawn(FrozenResult, self)
469
+
470
+ @overload
471
+ def scalars(
472
+ self: AsyncResult[_T, Unpack[TupleAny]], index: Literal[0]
473
+ ) -> AsyncScalarResult[_T]: ...
474
+
475
+ @overload
476
+ def scalars(
477
+ self: AsyncResult[_T, Unpack[TupleAny]],
478
+ ) -> AsyncScalarResult[_T]: ...
479
+
480
+ @overload
481
+ def scalars(self, index: _KeyIndexType = 0) -> AsyncScalarResult[Any]: ...
482
+
483
+ def scalars(self, index: _KeyIndexType = 0) -> AsyncScalarResult[Any]:
484
+ """Return an :class:`_asyncio.AsyncScalarResult` filtering object which
485
+ will return single elements rather than :class:`_row.Row` objects.
486
+
487
+ Refer to :meth:`_result.Result.scalars` in the synchronous
488
+ SQLAlchemy API for a complete behavioral description.
489
+
490
+ :param index: integer or row key indicating the column to be fetched
491
+ from each row, defaults to ``0`` indicating the first column.
492
+
493
+ :return: a new :class:`_asyncio.AsyncScalarResult` filtering object
494
+ referring to this :class:`_asyncio.AsyncResult` object.
495
+
496
+ """
497
+ return AsyncScalarResult(self._real_result, index)
498
+
499
+ def mappings(self) -> AsyncMappingResult:
500
+ """Apply a mappings filter to returned rows, returning an instance of
501
+ :class:`_asyncio.AsyncMappingResult`.
502
+
503
+ When this filter is applied, fetching rows will return
504
+ :class:`_engine.RowMapping` objects instead of :class:`_engine.Row`
505
+ objects.
506
+
507
+ :return: a new :class:`_asyncio.AsyncMappingResult` filtering object
508
+ referring to the underlying :class:`_result.Result` object.
509
+
510
+ """
511
+
512
+ return AsyncMappingResult(self._real_result)
513
+
514
+
515
+ class AsyncScalarResult(AsyncCommon[_R]):
516
+ """A wrapper for a :class:`_asyncio.AsyncResult` that returns scalar values
517
+ rather than :class:`_row.Row` values.
518
+
519
+ The :class:`_asyncio.AsyncScalarResult` object is acquired by calling the
520
+ :meth:`_asyncio.AsyncResult.scalars` method.
521
+
522
+ Refer to the :class:`_result.ScalarResult` object in the synchronous
523
+ SQLAlchemy API for a complete behavioral description.
524
+
525
+ .. versionadded:: 1.4
526
+
527
+ """
528
+
529
+ __slots__ = ()
530
+
531
+ _generate_rows = False
532
+
533
+ def __init__(
534
+ self,
535
+ real_result: Result[Unpack[TupleAny]],
536
+ index: _KeyIndexType,
537
+ ):
538
+ self._real_result = real_result
539
+
540
+ if real_result._source_supports_scalars:
541
+ self._metadata = real_result._metadata
542
+ self._post_creational_filter = None
543
+ else:
544
+ self._metadata = real_result._metadata._reduce([index])
545
+ self._post_creational_filter = operator.itemgetter(0)
546
+
547
+ self._unique_filter_state = real_result._unique_filter_state
548
+
549
+ def unique(
550
+ self,
551
+ strategy: Optional[_UniqueFilterType] = None,
552
+ ) -> Self:
553
+ """Apply unique filtering to the objects returned by this
554
+ :class:`_asyncio.AsyncScalarResult`.
555
+
556
+ See :meth:`_asyncio.AsyncResult.unique` for usage details.
557
+
558
+ """
559
+ self._unique_filter_state = (set(), strategy)
560
+ return self
561
+
562
+ async def partitions(
563
+ self, size: Optional[int] = None
564
+ ) -> AsyncIterator[Sequence[_R]]:
565
+ """Iterate through sub-lists of elements of the size given.
566
+
567
+ Equivalent to :meth:`_asyncio.AsyncResult.partitions` except that
568
+ scalar values, rather than :class:`_engine.Row` objects,
569
+ are returned.
570
+
571
+ """
572
+
573
+ getter = self._manyrow_getter
574
+
575
+ while True:
576
+ partition = await greenlet_spawn(getter, self, size)
577
+ if partition:
578
+ yield partition
579
+ else:
580
+ break
581
+
582
+ async def fetchall(self) -> Sequence[_R]:
583
+ """A synonym for the :meth:`_asyncio.AsyncScalarResult.all` method."""
584
+
585
+ return await greenlet_spawn(self._allrows)
586
+
587
+ async def fetchmany(self, size: Optional[int] = None) -> Sequence[_R]:
588
+ """Fetch many objects.
589
+
590
+ Equivalent to :meth:`_asyncio.AsyncResult.fetchmany` except that
591
+ scalar values, rather than :class:`_engine.Row` objects,
592
+ are returned.
593
+
594
+ """
595
+ return await greenlet_spawn(self._manyrow_getter, self, size)
596
+
597
+ async def all(self) -> Sequence[_R]:
598
+ """Return all scalar values in a list.
599
+
600
+ Equivalent to :meth:`_asyncio.AsyncResult.all` except that
601
+ scalar values, rather than :class:`_engine.Row` objects,
602
+ are returned.
603
+
604
+ """
605
+ return await greenlet_spawn(self._allrows)
606
+
607
+ def __aiter__(self) -> AsyncScalarResult[_R]:
608
+ return self
609
+
610
+ async def __anext__(self) -> _R:
611
+ row = await greenlet_spawn(self._onerow_getter, self)
612
+ if row is _NO_ROW:
613
+ raise StopAsyncIteration()
614
+ else:
615
+ return row
616
+
617
+ async def first(self) -> Optional[_R]:
618
+ """Fetch the first object or ``None`` if no object is present.
619
+
620
+ Equivalent to :meth:`_asyncio.AsyncResult.first` except that
621
+ scalar values, rather than :class:`_engine.Row` objects,
622
+ are returned.
623
+
624
+ """
625
+ return await greenlet_spawn(self._only_one_row, False, False, False)
626
+
627
+ async def one_or_none(self) -> Optional[_R]:
628
+ """Return at most one object or raise an exception.
629
+
630
+ Equivalent to :meth:`_asyncio.AsyncResult.one_or_none` except that
631
+ scalar values, rather than :class:`_engine.Row` objects,
632
+ are returned.
633
+
634
+ """
635
+ return await greenlet_spawn(self._only_one_row, True, False, False)
636
+
637
+ async def one(self) -> _R:
638
+ """Return exactly one object or raise an exception.
639
+
640
+ Equivalent to :meth:`_asyncio.AsyncResult.one` except that
641
+ scalar values, rather than :class:`_engine.Row` objects,
642
+ are returned.
643
+
644
+ """
645
+ return await greenlet_spawn(self._only_one_row, True, True, False)
646
+
647
+
648
+ class AsyncMappingResult(_WithKeys, AsyncCommon[RowMapping]):
649
+ """A wrapper for a :class:`_asyncio.AsyncResult` that returns dictionary
650
+ values rather than :class:`_engine.Row` values.
651
+
652
+ The :class:`_asyncio.AsyncMappingResult` object is acquired by calling the
653
+ :meth:`_asyncio.AsyncResult.mappings` method.
654
+
655
+ Refer to the :class:`_result.MappingResult` object in the synchronous
656
+ SQLAlchemy API for a complete behavioral description.
657
+
658
+ .. versionadded:: 1.4
659
+
660
+ """
661
+
662
+ __slots__ = ()
663
+
664
+ _generate_rows = True
665
+
666
+ _post_creational_filter = operator.attrgetter("_mapping")
667
+
668
+ def __init__(self, result: Result[Unpack[TupleAny]]):
669
+ self._real_result = result
670
+ self._unique_filter_state = result._unique_filter_state
671
+ self._metadata = result._metadata
672
+ if result._source_supports_scalars:
673
+ self._metadata = self._metadata._reduce([0])
674
+
675
+ def unique(
676
+ self,
677
+ strategy: Optional[_UniqueFilterType] = None,
678
+ ) -> Self:
679
+ """Apply unique filtering to the objects returned by this
680
+ :class:`_asyncio.AsyncMappingResult`.
681
+
682
+ See :meth:`_asyncio.AsyncResult.unique` for usage details.
683
+
684
+ """
685
+ self._unique_filter_state = (set(), strategy)
686
+ return self
687
+
688
+ def columns(self, *col_expressions: _KeyIndexType) -> Self:
689
+ r"""Establish the columns that should be returned in each row."""
690
+ return self._column_slices(col_expressions)
691
+
692
+ async def partitions(
693
+ self, size: Optional[int] = None
694
+ ) -> AsyncIterator[Sequence[RowMapping]]:
695
+ """Iterate through sub-lists of elements of the size given.
696
+
697
+ Equivalent to :meth:`_asyncio.AsyncResult.partitions` except that
698
+ :class:`_engine.RowMapping` values, rather than :class:`_engine.Row`
699
+ objects, are returned.
700
+
701
+ """
702
+
703
+ getter = self._manyrow_getter
704
+
705
+ while True:
706
+ partition = await greenlet_spawn(getter, self, size)
707
+ if partition:
708
+ yield partition
709
+ else:
710
+ break
711
+
712
+ async def fetchall(self) -> Sequence[RowMapping]:
713
+ """A synonym for the :meth:`_asyncio.AsyncMappingResult.all` method."""
714
+
715
+ return await greenlet_spawn(self._allrows)
716
+
717
+ async def fetchone(self) -> Optional[RowMapping]:
718
+ """Fetch one object.
719
+
720
+ Equivalent to :meth:`_asyncio.AsyncResult.fetchone` except that
721
+ :class:`_engine.RowMapping` values, rather than :class:`_engine.Row`
722
+ objects, are returned.
723
+
724
+ """
725
+
726
+ row = await greenlet_spawn(self._onerow_getter, self)
727
+ if row is _NO_ROW:
728
+ return None
729
+ else:
730
+ return row
731
+
732
+ async def fetchmany(
733
+ self, size: Optional[int] = None
734
+ ) -> Sequence[RowMapping]:
735
+ """Fetch many rows.
736
+
737
+ Equivalent to :meth:`_asyncio.AsyncResult.fetchmany` except that
738
+ :class:`_engine.RowMapping` values, rather than :class:`_engine.Row`
739
+ objects, are returned.
740
+
741
+ """
742
+
743
+ return await greenlet_spawn(self._manyrow_getter, self, size)
744
+
745
+ async def all(self) -> Sequence[RowMapping]:
746
+ """Return all rows in a list.
747
+
748
+ Equivalent to :meth:`_asyncio.AsyncResult.all` except that
749
+ :class:`_engine.RowMapping` values, rather than :class:`_engine.Row`
750
+ objects, are returned.
751
+
752
+ """
753
+
754
+ return await greenlet_spawn(self._allrows)
755
+
756
+ def __aiter__(self) -> AsyncMappingResult:
757
+ return self
758
+
759
+ async def __anext__(self) -> RowMapping:
760
+ row = await greenlet_spawn(self._onerow_getter, self)
761
+ if row is _NO_ROW:
762
+ raise StopAsyncIteration()
763
+ else:
764
+ return row
765
+
766
+ async def first(self) -> Optional[RowMapping]:
767
+ """Fetch the first object or ``None`` if no object is present.
768
+
769
+ Equivalent to :meth:`_asyncio.AsyncResult.first` except that
770
+ :class:`_engine.RowMapping` values, rather than :class:`_engine.Row`
771
+ objects, are returned.
772
+
773
+ """
774
+ return await greenlet_spawn(self._only_one_row, False, False, False)
775
+
776
+ async def one_or_none(self) -> Optional[RowMapping]:
777
+ """Return at most one object or raise an exception.
778
+
779
+ Equivalent to :meth:`_asyncio.AsyncResult.one_or_none` except that
780
+ :class:`_engine.RowMapping` values, rather than :class:`_engine.Row`
781
+ objects, are returned.
782
+
783
+ """
784
+ return await greenlet_spawn(self._only_one_row, True, False, False)
785
+
786
+ async def one(self) -> RowMapping:
787
+ """Return exactly one object or raise an exception.
788
+
789
+ Equivalent to :meth:`_asyncio.AsyncResult.one` except that
790
+ :class:`_engine.RowMapping` values, rather than :class:`_engine.Row`
791
+ objects, are returned.
792
+
793
+ """
794
+ return await greenlet_spawn(self._only_one_row, True, True, False)
795
+
796
+
797
+ class AsyncTupleResult(AsyncCommon[_R], util.TypingOnly):
798
+ """A :class:`_asyncio.AsyncResult` that's typed as returning plain
799
+ Python tuples instead of rows.
800
+
801
+ Since :class:`_engine.Row` acts like a tuple in every way already,
802
+ this class is a typing only class, regular :class:`_asyncio.AsyncResult` is
803
+ still used at runtime.
804
+
805
+ """
806
+
807
+ __slots__ = ()
808
+
809
+ if TYPE_CHECKING:
810
+
811
+ async def partitions(
812
+ self, size: Optional[int] = None
813
+ ) -> AsyncIterator[Sequence[_R]]:
814
+ """Iterate through sub-lists of elements of the size given.
815
+
816
+ Equivalent to :meth:`_result.Result.partitions` except that
817
+ tuple values, rather than :class:`_engine.Row` objects,
818
+ are returned.
819
+
820
+ """
821
+ ...
822
+
823
+ async def fetchone(self) -> Optional[_R]:
824
+ """Fetch one tuple.
825
+
826
+ Equivalent to :meth:`_result.Result.fetchone` except that
827
+ tuple values, rather than :class:`_engine.Row`
828
+ objects, are returned.
829
+
830
+ """
831
+ ...
832
+
833
+ async def fetchall(self) -> Sequence[_R]:
834
+ """A synonym for the :meth:`_engine.ScalarResult.all` method."""
835
+ ...
836
+
837
+ async def fetchmany(self, size: Optional[int] = None) -> Sequence[_R]:
838
+ """Fetch many objects.
839
+
840
+ Equivalent to :meth:`_result.Result.fetchmany` except that
841
+ tuple values, rather than :class:`_engine.Row` objects,
842
+ are returned.
843
+
844
+ """
845
+ ...
846
+
847
+ async def all(self) -> Sequence[_R]: # noqa: A001
848
+ """Return all scalar values in a list.
849
+
850
+ Equivalent to :meth:`_result.Result.all` except that
851
+ tuple values, rather than :class:`_engine.Row` objects,
852
+ are returned.
853
+
854
+ """
855
+ ...
856
+
857
+ def __aiter__(self) -> AsyncIterator[_R]: ...
858
+
859
+ async def __anext__(self) -> _R: ...
860
+
861
+ async def first(self) -> Optional[_R]:
862
+ """Fetch the first object or ``None`` if no object is present.
863
+
864
+ Equivalent to :meth:`_result.Result.first` except that
865
+ tuple values, rather than :class:`_engine.Row` objects,
866
+ are returned.
867
+
868
+
869
+ """
870
+ ...
871
+
872
+ async def one_or_none(self) -> Optional[_R]:
873
+ """Return at most one object or raise an exception.
874
+
875
+ Equivalent to :meth:`_result.Result.one_or_none` except that
876
+ tuple values, rather than :class:`_engine.Row` objects,
877
+ are returned.
878
+
879
+ """
880
+ ...
881
+
882
+ async def one(self) -> _R:
883
+ """Return exactly one object or raise an exception.
884
+
885
+ Equivalent to :meth:`_result.Result.one` except that
886
+ tuple values, rather than :class:`_engine.Row` objects,
887
+ are returned.
888
+
889
+ """
890
+ ...
891
+
892
+ @overload
893
+ async def scalar_one(self: AsyncTupleResult[Tuple[_T]]) -> _T: ...
894
+
895
+ @overload
896
+ async def scalar_one(self) -> Any: ...
897
+
898
+ async def scalar_one(self) -> Any:
899
+ """Return exactly one scalar result or raise an exception.
900
+
901
+ This is equivalent to calling :meth:`_engine.Result.scalars`
902
+ and then :meth:`_engine.AsyncScalarResult.one`.
903
+
904
+ .. seealso::
905
+
906
+ :meth:`_engine.AsyncScalarResult.one`
907
+
908
+ :meth:`_engine.Result.scalars`
909
+
910
+ """
911
+ ...
912
+
913
+ @overload
914
+ async def scalar_one_or_none(
915
+ self: AsyncTupleResult[Tuple[_T]],
916
+ ) -> Optional[_T]: ...
917
+
918
+ @overload
919
+ async def scalar_one_or_none(self) -> Optional[Any]: ...
920
+
921
+ async def scalar_one_or_none(self) -> Optional[Any]:
922
+ """Return exactly one or no scalar result.
923
+
924
+ This is equivalent to calling :meth:`_engine.Result.scalars`
925
+ and then :meth:`_engine.AsyncScalarResult.one_or_none`.
926
+
927
+ .. seealso::
928
+
929
+ :meth:`_engine.AsyncScalarResult.one_or_none`
930
+
931
+ :meth:`_engine.Result.scalars`
932
+
933
+ """
934
+ ...
935
+
936
+ @overload
937
+ async def scalar(
938
+ self: AsyncTupleResult[Tuple[_T]],
939
+ ) -> Optional[_T]: ...
940
+
941
+ @overload
942
+ async def scalar(self) -> Any: ...
943
+
944
+ async def scalar(self) -> Any:
945
+ """Fetch the first column of the first row, and close the result
946
+ set.
947
+
948
+ Returns ``None`` if there are no rows to fetch.
949
+
950
+ No validation is performed to test if additional rows remain.
951
+
952
+ After calling this method, the object is fully closed,
953
+ e.g. the :meth:`_engine.CursorResult.close`
954
+ method will have been called.
955
+
956
+ :return: a Python scalar value , or ``None`` if no rows remain.
957
+
958
+ """
959
+ ...
960
+
961
+
962
+ _RT = TypeVar("_RT", bound="Result[Unpack[TupleAny]]")
963
+
964
+
965
+ async def _ensure_sync_result(result: _RT, calling_method: Any) -> _RT:
966
+ cursor_result: CursorResult[Any]
967
+
968
+ try:
969
+ is_cursor = result._is_cursor
970
+ except AttributeError:
971
+ # legacy execute(DefaultGenerator) case
972
+ return result
973
+
974
+ if not is_cursor:
975
+ cursor_result = getattr(result, "raw", None) # type: ignore
976
+ else:
977
+ cursor_result = result # type: ignore
978
+ if cursor_result and cursor_result.context._is_server_side:
979
+ await greenlet_spawn(cursor_result.close)
980
+ raise async_exc.AsyncMethodRequired(
981
+ "Can't use the %s.%s() method with a "
982
+ "server-side cursor. "
983
+ "Use the %s.stream() method for an async "
984
+ "streaming result set."
985
+ % (
986
+ calling_method.__self__.__class__.__name__,
987
+ calling_method.__name__,
988
+ calling_method.__self__.__class__.__name__,
989
+ )
990
+ )
991
+
992
+ if is_cursor and cursor_result.cursor is not None:
993
+ await cursor_result.cursor._async_soft_close()
994
+ return result