SQLAlchemy 2.1.0b1__cp313-cp313-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 (267) hide show
  1. sqlalchemy/__init__.py +295 -0
  2. sqlalchemy/connectors/__init__.py +18 -0
  3. sqlalchemy/connectors/aioodbc.py +161 -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 +88 -0
  9. sqlalchemy/dialects/mssql/aioodbc.py +63 -0
  10. sqlalchemy/dialects/mssql/base.py +4110 -0
  11. sqlalchemy/dialects/mssql/information_schema.py +285 -0
  12. sqlalchemy/dialects/mssql/json.py +129 -0
  13. sqlalchemy/dialects/mssql/provision.py +185 -0
  14. sqlalchemy/dialects/mssql/pymssql.py +126 -0
  15. sqlalchemy/dialects/mssql/pyodbc.py +758 -0
  16. sqlalchemy/dialects/mysql/__init__.py +106 -0
  17. sqlalchemy/dialects/mysql/_mariadb_shim.py +312 -0
  18. sqlalchemy/dialects/mysql/aiomysql.py +226 -0
  19. sqlalchemy/dialects/mysql/asyncmy.py +214 -0
  20. sqlalchemy/dialects/mysql/base.py +3870 -0
  21. sqlalchemy/dialects/mysql/cymysql.py +106 -0
  22. sqlalchemy/dialects/mysql/dml.py +279 -0
  23. sqlalchemy/dialects/mysql/enumerated.py +277 -0
  24. sqlalchemy/dialects/mysql/expression.py +146 -0
  25. sqlalchemy/dialects/mysql/json.py +91 -0
  26. sqlalchemy/dialects/mysql/mariadb.py +67 -0
  27. sqlalchemy/dialects/mysql/mariadbconnector.py +330 -0
  28. sqlalchemy/dialects/mysql/mysqlconnector.py +296 -0
  29. sqlalchemy/dialects/mysql/mysqldb.py +312 -0
  30. sqlalchemy/dialects/mysql/provision.py +147 -0
  31. sqlalchemy/dialects/mysql/pymysql.py +157 -0
  32. sqlalchemy/dialects/mysql/pyodbc.py +156 -0
  33. sqlalchemy/dialects/mysql/reflection.py +724 -0
  34. sqlalchemy/dialects/mysql/reserved_words.py +570 -0
  35. sqlalchemy/dialects/mysql/types.py +845 -0
  36. sqlalchemy/dialects/oracle/__init__.py +83 -0
  37. sqlalchemy/dialects/oracle/base.py +3871 -0
  38. sqlalchemy/dialects/oracle/cx_oracle.py +1522 -0
  39. sqlalchemy/dialects/oracle/dictionary.py +507 -0
  40. sqlalchemy/dialects/oracle/oracledb.py +894 -0
  41. sqlalchemy/dialects/oracle/provision.py +288 -0
  42. sqlalchemy/dialects/oracle/types.py +350 -0
  43. sqlalchemy/dialects/oracle/vector.py +368 -0
  44. sqlalchemy/dialects/postgresql/__init__.py +171 -0
  45. sqlalchemy/dialects/postgresql/_psycopg_common.py +193 -0
  46. sqlalchemy/dialects/postgresql/array.py +534 -0
  47. sqlalchemy/dialects/postgresql/asyncpg.py +1331 -0
  48. sqlalchemy/dialects/postgresql/base.py +5729 -0
  49. sqlalchemy/dialects/postgresql/bitstring.py +327 -0
  50. sqlalchemy/dialects/postgresql/dml.py +360 -0
  51. sqlalchemy/dialects/postgresql/ext.py +593 -0
  52. sqlalchemy/dialects/postgresql/hstore.py +413 -0
  53. sqlalchemy/dialects/postgresql/json.py +407 -0
  54. sqlalchemy/dialects/postgresql/named_types.py +521 -0
  55. sqlalchemy/dialects/postgresql/operators.py +130 -0
  56. sqlalchemy/dialects/postgresql/pg8000.py +672 -0
  57. sqlalchemy/dialects/postgresql/pg_catalog.py +344 -0
  58. sqlalchemy/dialects/postgresql/provision.py +175 -0
  59. sqlalchemy/dialects/postgresql/psycopg.py +815 -0
  60. sqlalchemy/dialects/postgresql/psycopg2.py +887 -0
  61. sqlalchemy/dialects/postgresql/psycopg2cffi.py +61 -0
  62. sqlalchemy/dialects/postgresql/ranges.py +1002 -0
  63. sqlalchemy/dialects/postgresql/types.py +388 -0
  64. sqlalchemy/dialects/sqlite/__init__.py +57 -0
  65. sqlalchemy/dialects/sqlite/aiosqlite.py +321 -0
  66. sqlalchemy/dialects/sqlite/base.py +3050 -0
  67. sqlalchemy/dialects/sqlite/dml.py +279 -0
  68. sqlalchemy/dialects/sqlite/json.py +89 -0
  69. sqlalchemy/dialects/sqlite/provision.py +223 -0
  70. sqlalchemy/dialects/sqlite/pysqlcipher.py +157 -0
  71. sqlalchemy/dialects/sqlite/pysqlite.py +754 -0
  72. sqlalchemy/dialects/type_migration_guidelines.txt +145 -0
  73. sqlalchemy/engine/__init__.py +62 -0
  74. sqlalchemy/engine/_processors_cy.cp313-win_arm64.pyd +0 -0
  75. sqlalchemy/engine/_processors_cy.py +92 -0
  76. sqlalchemy/engine/_result_cy.cp313-win_arm64.pyd +0 -0
  77. sqlalchemy/engine/_result_cy.py +633 -0
  78. sqlalchemy/engine/_row_cy.cp313-win_arm64.pyd +0 -0
  79. sqlalchemy/engine/_row_cy.py +232 -0
  80. sqlalchemy/engine/_util_cy.cp313-win_arm64.pyd +0 -0
  81. sqlalchemy/engine/_util_cy.py +136 -0
  82. sqlalchemy/engine/base.py +3334 -0
  83. sqlalchemy/engine/characteristics.py +155 -0
  84. sqlalchemy/engine/create.py +869 -0
  85. sqlalchemy/engine/cursor.py +2416 -0
  86. sqlalchemy/engine/default.py +2393 -0
  87. sqlalchemy/engine/events.py +965 -0
  88. sqlalchemy/engine/interfaces.py +3465 -0
  89. sqlalchemy/engine/mock.py +134 -0
  90. sqlalchemy/engine/processors.py +82 -0
  91. sqlalchemy/engine/reflection.py +2100 -0
  92. sqlalchemy/engine/result.py +1932 -0
  93. sqlalchemy/engine/row.py +397 -0
  94. sqlalchemy/engine/strategies.py +16 -0
  95. sqlalchemy/engine/url.py +922 -0
  96. sqlalchemy/engine/util.py +156 -0
  97. sqlalchemy/event/__init__.py +26 -0
  98. sqlalchemy/event/api.py +220 -0
  99. sqlalchemy/event/attr.py +674 -0
  100. sqlalchemy/event/base.py +472 -0
  101. sqlalchemy/event/legacy.py +258 -0
  102. sqlalchemy/event/registry.py +390 -0
  103. sqlalchemy/events.py +17 -0
  104. sqlalchemy/exc.py +922 -0
  105. sqlalchemy/ext/__init__.py +11 -0
  106. sqlalchemy/ext/associationproxy.py +2072 -0
  107. sqlalchemy/ext/asyncio/__init__.py +29 -0
  108. sqlalchemy/ext/asyncio/base.py +281 -0
  109. sqlalchemy/ext/asyncio/engine.py +1475 -0
  110. sqlalchemy/ext/asyncio/exc.py +21 -0
  111. sqlalchemy/ext/asyncio/result.py +994 -0
  112. sqlalchemy/ext/asyncio/scoping.py +1667 -0
  113. sqlalchemy/ext/asyncio/session.py +1993 -0
  114. sqlalchemy/ext/automap.py +1701 -0
  115. sqlalchemy/ext/baked.py +559 -0
  116. sqlalchemy/ext/compiler.py +600 -0
  117. sqlalchemy/ext/declarative/__init__.py +65 -0
  118. sqlalchemy/ext/declarative/extensions.py +560 -0
  119. sqlalchemy/ext/horizontal_shard.py +481 -0
  120. sqlalchemy/ext/hybrid.py +1877 -0
  121. sqlalchemy/ext/indexable.py +364 -0
  122. sqlalchemy/ext/instrumentation.py +450 -0
  123. sqlalchemy/ext/mutable.py +1081 -0
  124. sqlalchemy/ext/orderinglist.py +439 -0
  125. sqlalchemy/ext/serializer.py +185 -0
  126. sqlalchemy/future/__init__.py +16 -0
  127. sqlalchemy/future/engine.py +15 -0
  128. sqlalchemy/inspection.py +174 -0
  129. sqlalchemy/log.py +283 -0
  130. sqlalchemy/orm/__init__.py +175 -0
  131. sqlalchemy/orm/_orm_constructors.py +2694 -0
  132. sqlalchemy/orm/_typing.py +179 -0
  133. sqlalchemy/orm/attributes.py +2868 -0
  134. sqlalchemy/orm/base.py +970 -0
  135. sqlalchemy/orm/bulk_persistence.py +2152 -0
  136. sqlalchemy/orm/clsregistry.py +582 -0
  137. sqlalchemy/orm/collections.py +1568 -0
  138. sqlalchemy/orm/context.py +3471 -0
  139. sqlalchemy/orm/decl_api.py +2257 -0
  140. sqlalchemy/orm/decl_base.py +2304 -0
  141. sqlalchemy/orm/dependency.py +1306 -0
  142. sqlalchemy/orm/descriptor_props.py +1183 -0
  143. sqlalchemy/orm/dynamic.py +300 -0
  144. sqlalchemy/orm/evaluator.py +379 -0
  145. sqlalchemy/orm/events.py +3386 -0
  146. sqlalchemy/orm/exc.py +237 -0
  147. sqlalchemy/orm/identity.py +302 -0
  148. sqlalchemy/orm/instrumentation.py +746 -0
  149. sqlalchemy/orm/interfaces.py +1589 -0
  150. sqlalchemy/orm/loading.py +1684 -0
  151. sqlalchemy/orm/mapped_collection.py +557 -0
  152. sqlalchemy/orm/mapper.py +4406 -0
  153. sqlalchemy/orm/path_registry.py +814 -0
  154. sqlalchemy/orm/persistence.py +1789 -0
  155. sqlalchemy/orm/properties.py +973 -0
  156. sqlalchemy/orm/query.py +3521 -0
  157. sqlalchemy/orm/relationships.py +3570 -0
  158. sqlalchemy/orm/scoping.py +2220 -0
  159. sqlalchemy/orm/session.py +5389 -0
  160. sqlalchemy/orm/state.py +1175 -0
  161. sqlalchemy/orm/state_changes.py +196 -0
  162. sqlalchemy/orm/strategies.py +3480 -0
  163. sqlalchemy/orm/strategy_options.py +2544 -0
  164. sqlalchemy/orm/sync.py +164 -0
  165. sqlalchemy/orm/unitofwork.py +798 -0
  166. sqlalchemy/orm/util.py +2435 -0
  167. sqlalchemy/orm/writeonly.py +694 -0
  168. sqlalchemy/pool/__init__.py +41 -0
  169. sqlalchemy/pool/base.py +1514 -0
  170. sqlalchemy/pool/events.py +372 -0
  171. sqlalchemy/pool/impl.py +582 -0
  172. sqlalchemy/py.typed +0 -0
  173. sqlalchemy/schema.py +72 -0
  174. sqlalchemy/sql/__init__.py +153 -0
  175. sqlalchemy/sql/_dml_constructors.py +132 -0
  176. sqlalchemy/sql/_elements_constructors.py +2147 -0
  177. sqlalchemy/sql/_orm_types.py +20 -0
  178. sqlalchemy/sql/_selectable_constructors.py +773 -0
  179. sqlalchemy/sql/_typing.py +486 -0
  180. sqlalchemy/sql/_util_cy.cp313-win_arm64.pyd +0 -0
  181. sqlalchemy/sql/_util_cy.py +127 -0
  182. sqlalchemy/sql/annotation.py +590 -0
  183. sqlalchemy/sql/base.py +2602 -0
  184. sqlalchemy/sql/cache_key.py +1066 -0
  185. sqlalchemy/sql/coercions.py +1373 -0
  186. sqlalchemy/sql/compiler.py +8259 -0
  187. sqlalchemy/sql/crud.py +1807 -0
  188. sqlalchemy/sql/ddl.py +1928 -0
  189. sqlalchemy/sql/default_comparator.py +654 -0
  190. sqlalchemy/sql/dml.py +1974 -0
  191. sqlalchemy/sql/elements.py +6016 -0
  192. sqlalchemy/sql/events.py +458 -0
  193. sqlalchemy/sql/expression.py +170 -0
  194. sqlalchemy/sql/functions.py +2257 -0
  195. sqlalchemy/sql/lambdas.py +1443 -0
  196. sqlalchemy/sql/naming.py +209 -0
  197. sqlalchemy/sql/operators.py +2897 -0
  198. sqlalchemy/sql/roles.py +332 -0
  199. sqlalchemy/sql/schema.py +6560 -0
  200. sqlalchemy/sql/selectable.py +7497 -0
  201. sqlalchemy/sql/sqltypes.py +4050 -0
  202. sqlalchemy/sql/traversals.py +1042 -0
  203. sqlalchemy/sql/type_api.py +2425 -0
  204. sqlalchemy/sql/util.py +1495 -0
  205. sqlalchemy/sql/visitors.py +1157 -0
  206. sqlalchemy/testing/__init__.py +96 -0
  207. sqlalchemy/testing/assertions.py +1007 -0
  208. sqlalchemy/testing/assertsql.py +519 -0
  209. sqlalchemy/testing/asyncio.py +128 -0
  210. sqlalchemy/testing/config.py +440 -0
  211. sqlalchemy/testing/engines.py +478 -0
  212. sqlalchemy/testing/entities.py +117 -0
  213. sqlalchemy/testing/exclusions.py +476 -0
  214. sqlalchemy/testing/fixtures/__init__.py +30 -0
  215. sqlalchemy/testing/fixtures/base.py +366 -0
  216. sqlalchemy/testing/fixtures/mypy.py +247 -0
  217. sqlalchemy/testing/fixtures/orm.py +227 -0
  218. sqlalchemy/testing/fixtures/sql.py +538 -0
  219. sqlalchemy/testing/pickleable.py +155 -0
  220. sqlalchemy/testing/plugin/__init__.py +6 -0
  221. sqlalchemy/testing/plugin/bootstrap.py +51 -0
  222. sqlalchemy/testing/plugin/plugin_base.py +828 -0
  223. sqlalchemy/testing/plugin/pytestplugin.py +892 -0
  224. sqlalchemy/testing/profiling.py +329 -0
  225. sqlalchemy/testing/provision.py +596 -0
  226. sqlalchemy/testing/requirements.py +1973 -0
  227. sqlalchemy/testing/schema.py +198 -0
  228. sqlalchemy/testing/suite/__init__.py +19 -0
  229. sqlalchemy/testing/suite/test_cte.py +237 -0
  230. sqlalchemy/testing/suite/test_ddl.py +420 -0
  231. sqlalchemy/testing/suite/test_dialect.py +776 -0
  232. sqlalchemy/testing/suite/test_insert.py +630 -0
  233. sqlalchemy/testing/suite/test_reflection.py +3557 -0
  234. sqlalchemy/testing/suite/test_results.py +660 -0
  235. sqlalchemy/testing/suite/test_rowcount.py +258 -0
  236. sqlalchemy/testing/suite/test_select.py +2112 -0
  237. sqlalchemy/testing/suite/test_sequence.py +317 -0
  238. sqlalchemy/testing/suite/test_table_via_select.py +686 -0
  239. sqlalchemy/testing/suite/test_types.py +2253 -0
  240. sqlalchemy/testing/suite/test_unicode_ddl.py +189 -0
  241. sqlalchemy/testing/suite/test_update_delete.py +139 -0
  242. sqlalchemy/testing/util.py +535 -0
  243. sqlalchemy/testing/warnings.py +52 -0
  244. sqlalchemy/types.py +76 -0
  245. sqlalchemy/util/__init__.py +157 -0
  246. sqlalchemy/util/_collections.py +693 -0
  247. sqlalchemy/util/_collections_cy.cp313-win_arm64.pyd +0 -0
  248. sqlalchemy/util/_collections_cy.pxd +8 -0
  249. sqlalchemy/util/_collections_cy.py +516 -0
  250. sqlalchemy/util/_has_cython.py +46 -0
  251. sqlalchemy/util/_immutabledict_cy.cp313-win_arm64.pyd +0 -0
  252. sqlalchemy/util/_immutabledict_cy.py +240 -0
  253. sqlalchemy/util/compat.py +287 -0
  254. sqlalchemy/util/concurrency.py +322 -0
  255. sqlalchemy/util/cython.py +79 -0
  256. sqlalchemy/util/deprecations.py +401 -0
  257. sqlalchemy/util/langhelpers.py +2256 -0
  258. sqlalchemy/util/preloaded.py +152 -0
  259. sqlalchemy/util/queue.py +304 -0
  260. sqlalchemy/util/tool_support.py +201 -0
  261. sqlalchemy/util/topological.py +120 -0
  262. sqlalchemy/util/typing.py +711 -0
  263. sqlalchemy-2.1.0b1.dist-info/METADATA +267 -0
  264. sqlalchemy-2.1.0b1.dist-info/RECORD +267 -0
  265. sqlalchemy-2.1.0b1.dist-info/WHEEL +5 -0
  266. sqlalchemy-2.1.0b1.dist-info/licenses/LICENSE +19 -0
  267. sqlalchemy-2.1.0b1.dist-info/top_level.txt +1 -0
@@ -0,0 +1,397 @@
1
+ # engine/row.py
2
+ # Copyright (C) 2005-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
+
8
+ """Define row constructs including :class:`.Row`."""
9
+
10
+ from __future__ import annotations
11
+
12
+ from abc import ABC
13
+ import collections.abc as collections_abc
14
+ import operator
15
+ import typing
16
+ from typing import Any
17
+ from typing import Callable
18
+ from typing import Dict
19
+ from typing import Generic
20
+ from typing import Iterator
21
+ from typing import Mapping
22
+ from typing import Optional
23
+ from typing import Sequence
24
+ from typing import Tuple
25
+ from typing import TYPE_CHECKING
26
+
27
+ from ._row_cy import BaseRow as BaseRow
28
+ from ..sql import util as sql_util
29
+ from ..util import deprecated
30
+ from ..util.typing import TypeVarTuple
31
+ from ..util.typing import Unpack
32
+
33
+ if TYPE_CHECKING:
34
+ from typing import Tuple as _RowBase
35
+
36
+ from .result import _KeyType
37
+ from .result import _ProcessorsType
38
+ from .result import RMKeyView
39
+ else:
40
+ _RowBase = Sequence
41
+
42
+
43
+ _Ts = TypeVarTuple("_Ts")
44
+
45
+
46
+ class Row(BaseRow, _RowBase[Unpack[_Ts]], Generic[Unpack[_Ts]]): # type: ignore[misc] # noqa: E501
47
+ """Represent a single result row.
48
+
49
+ The :class:`.Row` object represents a row of a database result. It is
50
+ typically associated in the 1.x series of SQLAlchemy with the
51
+ :class:`_engine.CursorResult` object, however is also used by the ORM for
52
+ tuple-like results as of SQLAlchemy 1.4.
53
+
54
+ The :class:`.Row` object seeks to act as much like a Python named
55
+ tuple as possible. For mapping (i.e. dictionary) behavior on a row,
56
+ such as testing for containment of keys, refer to the :attr:`.Row._mapping`
57
+ attribute.
58
+
59
+ .. seealso::
60
+
61
+ :ref:`tutorial_selecting_data` - includes examples of selecting
62
+ rows from SELECT statements.
63
+
64
+ .. versionchanged:: 1.4
65
+
66
+ Renamed ``RowProxy`` to :class:`.Row`. :class:`.Row` is no longer a
67
+ "proxy" object in that it contains the final form of data within it,
68
+ and now acts mostly like a named tuple. Mapping-like functionality is
69
+ moved to the :attr:`.Row._mapping` attribute. See
70
+ :ref:`change_4710_core` for background on this change.
71
+
72
+ """
73
+
74
+ __slots__ = ()
75
+
76
+ @deprecated(
77
+ "2.1.0",
78
+ "The :meth:`.Row._tuple` method is deprecated, :class:`.Row` "
79
+ "now behaves like a tuple and can unpack types directly.",
80
+ )
81
+ def _tuple(self) -> Tuple[Unpack[_Ts]]:
82
+ """Return a 'tuple' form of this :class:`.Row`.
83
+
84
+ At runtime, this method returns "self"; the :class:`.Row` object is
85
+ already a named tuple. However, at the typing level, if this
86
+ :class:`.Row` is typed, the "tuple" return type will be a :pep:`484`
87
+ ``Tuple`` datatype that contains typing information about individual
88
+ elements, supporting typed unpacking and attribute access.
89
+
90
+ .. versionadded:: 2.0.19 - The :meth:`.Row._tuple` method supersedes
91
+ the previous :meth:`.Row.tuple` method, which is now underscored
92
+ to avoid name conflicts with column names in the same way as other
93
+ named-tuple methods on :class:`.Row`.
94
+
95
+ .. seealso::
96
+
97
+ :ref:`change_10635` - describes a migration path from this
98
+ workaround for SQLAlchemy 2.1.
99
+
100
+ :attr:`.Row._t` - shorthand attribute notation
101
+
102
+ :meth:`.Result.tuples`
103
+
104
+
105
+ """
106
+ return self
107
+
108
+ @deprecated(
109
+ "2.0.19",
110
+ "The :meth:`.Row.tuple` method is deprecated in favor of "
111
+ ":meth:`.Row._tuple`; all :class:`.Row` "
112
+ "methods and library-level attributes are intended to be underscored "
113
+ "to avoid name conflicts. Please use :meth:`Row._tuple`.",
114
+ )
115
+ def tuple(self) -> Tuple[Unpack[_Ts]]:
116
+ """Return a 'tuple' form of this :class:`.Row`.
117
+
118
+ .. versionadded:: 2.0
119
+
120
+ .. seealso::
121
+
122
+ :ref:`change_10635` - describes a migration path from this
123
+ workaround for SQLAlchemy 2.1.
124
+
125
+ """
126
+ return self._tuple()
127
+
128
+ @property
129
+ @deprecated(
130
+ "2.1.0",
131
+ "The :attr:`.Row._t` attribute is deprecated, :class:`.Row` "
132
+ "now behaves like a tuple and can unpack types directly.",
133
+ )
134
+ def _t(self) -> Tuple[Unpack[_Ts]]:
135
+ """A synonym for :meth:`.Row._tuple`.
136
+
137
+ .. versionadded:: 2.0.19 - The :attr:`.Row._t` attribute supersedes
138
+ the previous :attr:`.Row.t` attribute, which is now underscored
139
+ to avoid name conflicts with column names in the same way as other
140
+ named-tuple methods on :class:`.Row`.
141
+
142
+ .. seealso::
143
+
144
+ :ref:`change_10635` - describes a migration path from this
145
+ workaround for SQLAlchemy 2.1.
146
+
147
+ :attr:`.Result.t`
148
+ """
149
+ return self
150
+
151
+ @property
152
+ @deprecated(
153
+ "2.0.19",
154
+ "The :attr:`.Row.t` attribute is deprecated in favor of "
155
+ ":attr:`.Row._t`; all :class:`.Row` "
156
+ "methods and library-level attributes are intended to be underscored "
157
+ "to avoid name conflicts. Please use :attr:`Row._t`.",
158
+ )
159
+ def t(self) -> Tuple[Unpack[_Ts]]:
160
+ """A synonym for :meth:`.Row._tuple`.
161
+
162
+ .. versionadded:: 2.0
163
+
164
+ .. seealso::
165
+
166
+ :ref:`change_10635` - describes a migration path from this
167
+ workaround for SQLAlchemy 2.1.
168
+
169
+ """
170
+ return self._t
171
+
172
+ @property
173
+ def _mapping(self) -> RowMapping:
174
+ """Return a :class:`.RowMapping` for this :class:`.Row`.
175
+
176
+ This object provides a consistent Python mapping (i.e. dictionary)
177
+ interface for the data contained within the row. The :class:`.Row`
178
+ by itself behaves like a named tuple.
179
+
180
+ .. seealso::
181
+
182
+ :attr:`.Row._fields`
183
+
184
+ .. versionadded:: 1.4
185
+
186
+ """
187
+ return RowMapping(self._parent, None, self._key_to_index, self._data)
188
+
189
+ def _filter_on_values(
190
+ self, processor: Optional[_ProcessorsType]
191
+ ) -> Row[Unpack[_Ts]]:
192
+ return Row(self._parent, processor, self._key_to_index, self._data)
193
+
194
+ if not TYPE_CHECKING:
195
+
196
+ def _special_name_accessor(name: str) -> Any:
197
+ """Handle ambiguous names such as "count" and "index" """
198
+
199
+ @property
200
+ def go(self: Row) -> Any:
201
+ if self._parent._has_key(name):
202
+ return self.__getattr__(name)
203
+ else:
204
+
205
+ def meth(*arg: Any, **kw: Any) -> Any:
206
+ return getattr(collections_abc.Sequence, name)(
207
+ self, *arg, **kw
208
+ )
209
+
210
+ return meth
211
+
212
+ return go
213
+
214
+ count = _special_name_accessor("count")
215
+ index = _special_name_accessor("index")
216
+
217
+ def _op(self, other: Any, op: Callable[[Any, Any], bool]) -> bool:
218
+ return (
219
+ op(self._to_tuple_instance(), other._to_tuple_instance())
220
+ if isinstance(other, Row)
221
+ else op(self._to_tuple_instance(), other)
222
+ )
223
+
224
+ __hash__ = BaseRow.__hash__
225
+
226
+ def __lt__(self, other: Any) -> bool:
227
+ return self._op(other, operator.lt)
228
+
229
+ def __le__(self, other: Any) -> bool:
230
+ return self._op(other, operator.le)
231
+
232
+ def __ge__(self, other: Any) -> bool:
233
+ return self._op(other, operator.ge)
234
+
235
+ def __gt__(self, other: Any) -> bool:
236
+ return self._op(other, operator.gt)
237
+
238
+ def __eq__(self, other: Any) -> bool:
239
+ return self._op(other, operator.eq)
240
+
241
+ def __ne__(self, other: Any) -> bool:
242
+ return self._op(other, operator.ne)
243
+
244
+ def __repr__(self) -> str:
245
+ return repr(sql_util._repr_row(self))
246
+
247
+ @property
248
+ def _fields(self) -> Tuple[str, ...]:
249
+ """Return a tuple of string keys as represented by this
250
+ :class:`.Row`.
251
+
252
+ The keys can represent the labels of the columns returned by a core
253
+ statement or the names of the orm classes returned by an orm
254
+ execution.
255
+
256
+ This attribute is analogous to the Python named tuple ``._fields``
257
+ attribute.
258
+
259
+ .. versionadded:: 1.4
260
+
261
+ .. seealso::
262
+
263
+ :attr:`.Row._mapping`
264
+
265
+ """
266
+ return tuple([k for k in self._parent.keys if k is not None])
267
+
268
+ def _asdict(self) -> Dict[str, Any]:
269
+ """Return a new dict which maps field names to their corresponding
270
+ values.
271
+
272
+ This method is analogous to the Python named tuple ``._asdict()``
273
+ method, and works by applying the ``dict()`` constructor to the
274
+ :attr:`.Row._mapping` attribute.
275
+
276
+ .. versionadded:: 1.4
277
+
278
+ .. seealso::
279
+
280
+ :attr:`.Row._mapping`
281
+
282
+ """
283
+ return dict(self._mapping)
284
+
285
+
286
+ BaseRowProxy = BaseRow
287
+ RowProxy = Row
288
+
289
+
290
+ class ROMappingView(ABC):
291
+ __slots__ = ()
292
+
293
+ _items: Sequence[Any]
294
+ _mapping: Mapping["_KeyType", Any]
295
+
296
+ def __init__(
297
+ self, mapping: Mapping["_KeyType", Any], items: Sequence[Any]
298
+ ):
299
+ self._mapping = mapping # type: ignore[misc]
300
+ self._items = items # type: ignore[misc]
301
+
302
+ def __len__(self) -> int:
303
+ return len(self._items)
304
+
305
+ def __repr__(self) -> str:
306
+ return "{0.__class__.__name__}({0._mapping!r})".format(self)
307
+
308
+ def __iter__(self) -> Iterator[Any]:
309
+ return iter(self._items)
310
+
311
+ def __contains__(self, item: Any) -> bool:
312
+ return item in self._items
313
+
314
+ def __eq__(self, other: Any) -> bool:
315
+ return list(other) == list(self)
316
+
317
+ def __ne__(self, other: Any) -> bool:
318
+ return list(other) != list(self)
319
+
320
+
321
+ class ROMappingKeysValuesView(
322
+ ROMappingView, typing.KeysView["_KeyType"], typing.ValuesView[Any]
323
+ ):
324
+ __slots__ = ("_items",) # mapping slot is provided by KeysView
325
+
326
+
327
+ class ROMappingItemsView(ROMappingView, typing.ItemsView["_KeyType", Any]):
328
+ __slots__ = ("_items",) # mapping slot is provided by ItemsView
329
+
330
+
331
+ class RowMapping(BaseRow, typing.Mapping["_KeyType", Any]):
332
+ """A ``Mapping`` that maps column names and objects to :class:`.Row`
333
+ values.
334
+
335
+ The :class:`.RowMapping` is available from a :class:`.Row` via the
336
+ :attr:`.Row._mapping` attribute, as well as from the iterable interface
337
+ provided by the :class:`.MappingResult` object returned by the
338
+ :meth:`_engine.Result.mappings` method.
339
+
340
+ :class:`.RowMapping` supplies Python mapping (i.e. dictionary) access to
341
+ the contents of the row. This includes support for testing of
342
+ containment of specific keys (string column names or objects), as well
343
+ as iteration of keys, values, and items::
344
+
345
+ for row in result:
346
+ if "a" in row._mapping:
347
+ print("Column 'a': %s" % row._mapping["a"])
348
+
349
+ print("Column b: %s" % row._mapping[table.c.b])
350
+
351
+ .. versionadded:: 1.4 The :class:`.RowMapping` object replaces the
352
+ mapping-like access previously provided by a database result row,
353
+ which now seeks to behave mostly like a named tuple.
354
+
355
+ """
356
+
357
+ __slots__ = ()
358
+
359
+ if TYPE_CHECKING:
360
+
361
+ def __getitem__(self, key: _KeyType) -> Any: ...
362
+
363
+ else:
364
+ __getitem__ = BaseRow._get_by_key_impl_mapping
365
+
366
+ def __iter__(self) -> Iterator[str]:
367
+ return (k for k in self._parent.keys if k is not None)
368
+
369
+ def __contains__(self, key: object) -> bool:
370
+ return self._parent._has_key(key)
371
+
372
+ def __repr__(self) -> str:
373
+ return repr(dict(self))
374
+
375
+ def items(self) -> ROMappingItemsView:
376
+ """Return a view of key/value tuples for the elements in the
377
+ underlying :class:`.Row`.
378
+
379
+ """
380
+ return ROMappingItemsView(
381
+ self, [(key, self[key]) for key in self.keys()]
382
+ )
383
+
384
+ def keys(self) -> RMKeyView:
385
+ """Return a view of 'keys' for string column names represented
386
+ by the underlying :class:`.Row`.
387
+
388
+ """
389
+
390
+ return self._parent.keys
391
+
392
+ def values(self) -> ROMappingKeysValuesView:
393
+ """Return a view of values for the values represented in the
394
+ underlying :class:`.Row`.
395
+
396
+ """
397
+ return ROMappingKeysValuesView(self, self._values_impl())
@@ -0,0 +1,16 @@
1
+ # engine/strategies.py
2
+ # Copyright (C) 2005-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
+
8
+ """Deprecated mock engine strategy used by Alembic."""
9
+
10
+ from __future__ import annotations
11
+
12
+ from .mock import MockConnection # noqa
13
+
14
+
15
+ class MockEngineStrategy:
16
+ MockConnection = MockConnection