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,1487 @@
1
+ # ext/asyncio/engine.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 asyncio
10
+ import contextlib
11
+ from typing import Any
12
+ from typing import AsyncIterator
13
+ from typing import Callable
14
+ from typing import Concatenate
15
+ from typing import Dict
16
+ from typing import Generator
17
+ from typing import NoReturn
18
+ from typing import Optional
19
+ from typing import overload
20
+ from typing import ParamSpec
21
+ from typing import Type
22
+ from typing import TYPE_CHECKING
23
+ from typing import TypeVar
24
+ from typing import Union
25
+
26
+ from . import exc as async_exc
27
+ from .base import asyncstartablecontext
28
+ from .base import GeneratorStartableContext
29
+ from .base import ProxyComparable
30
+ from .base import StartableContext
31
+ from .result import _ensure_sync_result
32
+ from .result import AsyncResult
33
+ from .result import AsyncScalarResult
34
+ from ... import exc
35
+ from ... import inspection
36
+ from ... import util
37
+ from ...engine import Connection
38
+ from ...engine import create_engine as _create_engine
39
+ from ...engine import create_pool_from_url as _create_pool_from_url
40
+ from ...engine import Engine
41
+ from ...engine.base import NestedTransaction
42
+ from ...engine.base import Transaction
43
+ from ...exc import ArgumentError
44
+ from ...util import immutabledict
45
+ from ...util.concurrency import greenlet_spawn
46
+ from ...util.typing import Never
47
+ from ...util.typing import TupleAny
48
+ from ...util.typing import TypeVarTuple
49
+ from ...util.typing import Unpack
50
+
51
+ if TYPE_CHECKING:
52
+ from ...engine.cursor import CursorResult
53
+ from ...engine.interfaces import _CoreAnyExecuteParams
54
+ from ...engine.interfaces import _CoreSingleExecuteParams
55
+ from ...engine.interfaces import _DBAPIAnyExecuteParams
56
+ from ...engine.interfaces import _ExecuteOptions
57
+ from ...engine.interfaces import CompiledCacheType
58
+ from ...engine.interfaces import CoreExecuteOptionsParameter
59
+ from ...engine.interfaces import Dialect
60
+ from ...engine.interfaces import IsolationLevel
61
+ from ...engine.interfaces import SchemaTranslateMapType
62
+ from ...engine.result import ScalarResult
63
+ from ...engine.url import URL
64
+ from ...pool import Pool
65
+ from ...pool import PoolProxiedConnection
66
+ from ...sql._typing import _InfoType
67
+ from ...sql.base import Executable
68
+ from ...sql.selectable import TypedReturnsRows
69
+
70
+ _P = ParamSpec("_P")
71
+ _T = TypeVar("_T", bound=Any)
72
+ _Ts = TypeVarTuple("_Ts")
73
+ _stream_results = immutabledict(stream_results=True)
74
+
75
+
76
+ def create_async_engine(url: Union[str, URL], **kw: Any) -> AsyncEngine:
77
+ """Create a new async engine instance.
78
+
79
+ Arguments passed to :func:`_asyncio.create_async_engine` are mostly
80
+ identical to those passed to the :func:`_sa.create_engine` function.
81
+ The specified dialect must be an asyncio-compatible dialect
82
+ such as :ref:`dialect-postgresql-asyncpg`.
83
+
84
+ .. versionadded:: 1.4
85
+
86
+ :param async_creator: an async callable which returns a driver-level
87
+ asyncio connection. If given, the function should take no arguments,
88
+ and return a new asyncio connection from the underlying asyncio
89
+ database driver; the connection will be wrapped in the appropriate
90
+ structures to be used with the :class:`.AsyncEngine`. Note that the
91
+ parameters specified in the URL are not applied here, and the creator
92
+ function should use its own connection parameters.
93
+
94
+ This parameter is the asyncio equivalent of the
95
+ :paramref:`_sa.create_engine.creator` parameter of the
96
+ :func:`_sa.create_engine` function.
97
+
98
+ .. versionadded:: 2.0.16
99
+
100
+ """
101
+
102
+ if kw.get("server_side_cursors", False):
103
+ raise async_exc.AsyncMethodRequired(
104
+ "Can't set server_side_cursors for async engine globally; "
105
+ "use the connection.stream() method for an async "
106
+ "streaming result set"
107
+ )
108
+ kw["_is_async"] = True
109
+ async_creator = kw.pop("async_creator", None)
110
+ if async_creator:
111
+ if kw.get("creator", None):
112
+ raise ArgumentError(
113
+ "Can only specify one of 'async_creator' or 'creator', "
114
+ "not both."
115
+ )
116
+
117
+ def creator() -> Any:
118
+ # note that to send adapted arguments like
119
+ # prepared_statement_cache_size, user would use
120
+ # "creator" and emulate this form here
121
+ return sync_engine.dialect.dbapi.connect( # type: ignore
122
+ async_creator_fn=async_creator
123
+ )
124
+
125
+ kw["creator"] = creator
126
+ sync_engine = _create_engine(url, **kw)
127
+ return AsyncEngine(sync_engine)
128
+
129
+
130
+ def async_engine_from_config(
131
+ configuration: Dict[str, Any], prefix: str = "sqlalchemy.", **kwargs: Any
132
+ ) -> AsyncEngine:
133
+ """Create a new AsyncEngine instance using a configuration dictionary.
134
+
135
+ This function is analogous to the :func:`_sa.engine_from_config` function
136
+ in SQLAlchemy Core, except that the requested dialect must be an
137
+ asyncio-compatible dialect such as :ref:`dialect-postgresql-asyncpg`.
138
+ The argument signature of the function is identical to that
139
+ of :func:`_sa.engine_from_config`.
140
+
141
+ .. versionadded:: 1.4.29
142
+
143
+ """
144
+ options = {
145
+ key[len(prefix) :]: value
146
+ for key, value in configuration.items()
147
+ if key.startswith(prefix)
148
+ }
149
+ options["_coerce_config"] = True
150
+ options.update(kwargs)
151
+ url = options.pop("url")
152
+ return create_async_engine(url, **options)
153
+
154
+
155
+ def create_async_pool_from_url(url: Union[str, URL], **kwargs: Any) -> Pool:
156
+ """Create a new async engine instance.
157
+
158
+ Arguments passed to :func:`_asyncio.create_async_pool_from_url` are mostly
159
+ identical to those passed to the :func:`_sa.create_pool_from_url` function.
160
+ The specified dialect must be an asyncio-compatible dialect
161
+ such as :ref:`dialect-postgresql-asyncpg`.
162
+
163
+ .. versionadded:: 2.0.10
164
+
165
+ """
166
+ kwargs["_is_async"] = True
167
+ return _create_pool_from_url(url, **kwargs)
168
+
169
+
170
+ class AsyncConnectable:
171
+ __slots__ = "_slots_dispatch", "__weakref__"
172
+
173
+ @classmethod
174
+ def _no_async_engine_events(cls) -> NoReturn:
175
+ raise NotImplementedError(
176
+ "asynchronous events are not implemented at this time. Apply "
177
+ "synchronous listeners to the AsyncEngine.sync_engine or "
178
+ "AsyncConnection.sync_connection attributes."
179
+ )
180
+
181
+
182
+ @util.create_proxy_methods(
183
+ Connection,
184
+ ":class:`_engine.Connection`",
185
+ ":class:`_asyncio.AsyncConnection`",
186
+ classmethods=[],
187
+ methods=[],
188
+ attributes=[
189
+ "closed",
190
+ "invalidated",
191
+ "dialect",
192
+ "default_isolation_level",
193
+ ],
194
+ )
195
+ # "Class has incompatible disjoint bases" - no idea
196
+ class AsyncConnection( # type:ignore[misc]
197
+ ProxyComparable[Connection],
198
+ StartableContext["AsyncConnection"],
199
+ AsyncConnectable,
200
+ ):
201
+ """An asyncio proxy for a :class:`_engine.Connection`.
202
+
203
+ :class:`_asyncio.AsyncConnection` is acquired using the
204
+ :meth:`_asyncio.AsyncEngine.connect`
205
+ method of :class:`_asyncio.AsyncEngine`::
206
+
207
+ from sqlalchemy.ext.asyncio import create_async_engine
208
+
209
+ engine = create_async_engine("postgresql+asyncpg://user:pass@host/dbname")
210
+
211
+ async with engine.connect() as conn:
212
+ result = await conn.execute(select(table))
213
+
214
+ .. versionadded:: 1.4
215
+
216
+ """ # noqa
217
+
218
+ # AsyncConnection is a thin proxy; no state should be added here
219
+ # that is not retrievable from the "sync" engine / connection, e.g.
220
+ # current transaction, info, etc. It should be possible to
221
+ # create a new AsyncConnection that matches this one given only the
222
+ # "sync" elements.
223
+ __slots__ = (
224
+ "engine",
225
+ "sync_engine",
226
+ "sync_connection",
227
+ )
228
+
229
+ def __init__(
230
+ self,
231
+ async_engine: AsyncEngine,
232
+ sync_connection: Optional[Connection] = None,
233
+ ):
234
+ self.engine = async_engine
235
+ self.sync_engine = async_engine.sync_engine
236
+ self.sync_connection = self._assign_proxied(sync_connection)
237
+
238
+ sync_connection: Optional[Connection]
239
+ """Reference to the sync-style :class:`_engine.Connection` this
240
+ :class:`_asyncio.AsyncConnection` proxies requests towards.
241
+
242
+ This instance can be used as an event target.
243
+
244
+ .. seealso::
245
+
246
+ :ref:`asyncio_events`
247
+
248
+ """
249
+
250
+ sync_engine: Engine
251
+ """Reference to the sync-style :class:`_engine.Engine` this
252
+ :class:`_asyncio.AsyncConnection` is associated with via its underlying
253
+ :class:`_engine.Connection`.
254
+
255
+ This instance can be used as an event target.
256
+
257
+ .. seealso::
258
+
259
+ :ref:`asyncio_events`
260
+
261
+ """
262
+
263
+ @classmethod
264
+ def _regenerate_proxy_for_target(
265
+ cls, target: Connection, **additional_kw: Any # noqa: U100
266
+ ) -> AsyncConnection:
267
+ return AsyncConnection(
268
+ AsyncEngine._retrieve_proxy_for_target(target.engine), target
269
+ )
270
+
271
+ async def start(
272
+ self, is_ctxmanager: bool = False # noqa: U100
273
+ ) -> AsyncConnection:
274
+ """Start this :class:`_asyncio.AsyncConnection` object's context
275
+ outside of using a Python ``with:`` block.
276
+
277
+ """
278
+ if self.sync_connection:
279
+ raise exc.InvalidRequestError("connection is already started")
280
+ self.sync_connection = self._assign_proxied(
281
+ await greenlet_spawn(self.sync_engine.connect)
282
+ )
283
+ return self
284
+
285
+ @property
286
+ def connection(self) -> NoReturn:
287
+ """Not implemented for async; call
288
+ :meth:`_asyncio.AsyncConnection.get_raw_connection`.
289
+ """
290
+ raise exc.InvalidRequestError(
291
+ "AsyncConnection.connection accessor is not implemented as the "
292
+ "attribute may need to reconnect on an invalidated connection. "
293
+ "Use the get_raw_connection() method."
294
+ )
295
+
296
+ async def get_raw_connection(self) -> PoolProxiedConnection:
297
+ """Return the pooled DBAPI-level connection in use by this
298
+ :class:`_asyncio.AsyncConnection`.
299
+
300
+ This is a SQLAlchemy connection-pool proxied connection
301
+ which then has the attribute
302
+ :attr:`_pool._ConnectionFairy.driver_connection` that refers to the
303
+ actual driver connection. Its
304
+ :attr:`_pool._ConnectionFairy.dbapi_connection` refers instead
305
+ to an :class:`_engine.AdaptedConnection` instance that
306
+ adapts the driver connection to the DBAPI protocol.
307
+
308
+ """
309
+
310
+ return await greenlet_spawn(getattr, self._proxied, "connection")
311
+
312
+ @util.ro_non_memoized_property
313
+ def info(self) -> _InfoType:
314
+ """Return the :attr:`_engine.Connection.info` dictionary of the
315
+ underlying :class:`_engine.Connection`.
316
+
317
+ This dictionary is freely writable for user-defined state to be
318
+ associated with the database connection.
319
+
320
+ This attribute is only available if the :class:`.AsyncConnection` is
321
+ currently connected. If the :attr:`.AsyncConnection.closed` attribute
322
+ is ``True``, then accessing this attribute will raise
323
+ :class:`.ResourceClosedError`.
324
+
325
+ .. versionadded:: 1.4.0b2
326
+
327
+ """
328
+ return self._proxied.info
329
+
330
+ @util.ro_non_memoized_property
331
+ def _proxied(self) -> Connection:
332
+ if not self.sync_connection:
333
+ self._raise_for_not_started()
334
+ return self.sync_connection
335
+
336
+ def begin(self) -> AsyncTransaction:
337
+ """Begin a transaction prior to autobegin occurring."""
338
+ assert self._proxied
339
+ return AsyncTransaction(self)
340
+
341
+ def begin_nested(self) -> AsyncTransaction:
342
+ """Begin a nested transaction and return a transaction handle."""
343
+ assert self._proxied
344
+ return AsyncTransaction(self, nested=True)
345
+
346
+ async def invalidate(
347
+ self, exception: Optional[BaseException] = None
348
+ ) -> None:
349
+ """Invalidate the underlying DBAPI connection associated with
350
+ this :class:`_engine.Connection`.
351
+
352
+ See the method :meth:`_engine.Connection.invalidate` for full
353
+ detail on this method.
354
+
355
+ """
356
+
357
+ return await greenlet_spawn(
358
+ self._proxied.invalidate, exception=exception
359
+ )
360
+
361
+ async def get_isolation_level(self) -> IsolationLevel:
362
+ return await greenlet_spawn(self._proxied.get_isolation_level)
363
+
364
+ def in_transaction(self) -> bool:
365
+ """Return True if a transaction is in progress."""
366
+
367
+ return self._proxied.in_transaction()
368
+
369
+ def in_nested_transaction(self) -> bool:
370
+ """Return True if a transaction is in progress.
371
+
372
+ .. versionadded:: 1.4.0b2
373
+
374
+ """
375
+ return self._proxied.in_nested_transaction()
376
+
377
+ def get_transaction(self) -> Optional[AsyncTransaction]:
378
+ """Return an :class:`.AsyncTransaction` representing the current
379
+ transaction, if any.
380
+
381
+ This makes use of the underlying synchronous connection's
382
+ :meth:`_engine.Connection.get_transaction` method to get the current
383
+ :class:`_engine.Transaction`, which is then proxied in a new
384
+ :class:`.AsyncTransaction` object.
385
+
386
+ .. versionadded:: 1.4.0b2
387
+
388
+ """
389
+
390
+ trans = self._proxied.get_transaction()
391
+ if trans is not None:
392
+ return AsyncTransaction._retrieve_proxy_for_target(trans)
393
+ else:
394
+ return None
395
+
396
+ def get_nested_transaction(self) -> Optional[AsyncTransaction]:
397
+ """Return an :class:`.AsyncTransaction` representing the current
398
+ nested (savepoint) transaction, if any.
399
+
400
+ This makes use of the underlying synchronous connection's
401
+ :meth:`_engine.Connection.get_nested_transaction` method to get the
402
+ current :class:`_engine.Transaction`, which is then proxied in a new
403
+ :class:`.AsyncTransaction` object.
404
+
405
+ .. versionadded:: 1.4.0b2
406
+
407
+ """
408
+
409
+ trans = self._proxied.get_nested_transaction()
410
+ if trans is not None:
411
+ return AsyncTransaction._retrieve_proxy_for_target(trans)
412
+ else:
413
+ return None
414
+
415
+ @overload
416
+ async def execution_options(
417
+ self,
418
+ *,
419
+ compiled_cache: Optional[CompiledCacheType] = ...,
420
+ logging_token: str = ...,
421
+ isolation_level: IsolationLevel = ...,
422
+ no_parameters: bool = False,
423
+ stream_results: bool = False,
424
+ max_row_buffer: int = ...,
425
+ yield_per: int = ...,
426
+ insertmanyvalues_page_size: int = ...,
427
+ schema_translate_map: Optional[SchemaTranslateMapType] = ...,
428
+ preserve_rowcount: bool = False,
429
+ driver_column_names: bool = False,
430
+ **opt: Any,
431
+ ) -> AsyncConnection: ...
432
+
433
+ @overload
434
+ async def execution_options(self, **opt: Any) -> AsyncConnection: ...
435
+
436
+ async def execution_options(self, **opt: Any) -> AsyncConnection:
437
+ r"""Set non-SQL options for the connection which take effect
438
+ during execution.
439
+
440
+ This returns this :class:`_asyncio.AsyncConnection` object with
441
+ the new options added.
442
+
443
+ See :meth:`_engine.Connection.execution_options` for full details
444
+ on this method.
445
+
446
+ """
447
+
448
+ conn = self._proxied
449
+ c2 = await greenlet_spawn(conn.execution_options, **opt)
450
+ assert c2 is conn
451
+ return self
452
+
453
+ async def commit(self) -> None:
454
+ """Commit the transaction that is currently in progress.
455
+
456
+ This method commits the current transaction if one has been started.
457
+ If no transaction was started, the method has no effect, assuming
458
+ the connection is in a non-invalidated state.
459
+
460
+ A transaction is begun on a :class:`_engine.Connection` automatically
461
+ whenever a statement is first executed, or when the
462
+ :meth:`_engine.Connection.begin` method is called.
463
+
464
+ """
465
+ await greenlet_spawn(self._proxied.commit)
466
+
467
+ async def rollback(self) -> None:
468
+ """Roll back the transaction that is currently in progress.
469
+
470
+ This method rolls back the current transaction if one has been started.
471
+ If no transaction was started, the method has no effect. If a
472
+ transaction was started and the connection is in an invalidated state,
473
+ the transaction is cleared using this method.
474
+
475
+ A transaction is begun on a :class:`_engine.Connection` automatically
476
+ whenever a statement is first executed, or when the
477
+ :meth:`_engine.Connection.begin` method is called.
478
+
479
+
480
+ """
481
+ await greenlet_spawn(self._proxied.rollback)
482
+
483
+ async def close(self) -> None:
484
+ """Close this :class:`_asyncio.AsyncConnection`.
485
+
486
+ This has the effect of also rolling back the transaction if one
487
+ is in place.
488
+
489
+ """
490
+ await greenlet_spawn(self._proxied.close)
491
+
492
+ async def aclose(self) -> None:
493
+ """A synonym for :meth:`_asyncio.AsyncConnection.close`.
494
+
495
+ The :meth:`_asyncio.AsyncConnection.aclose` name is specifically
496
+ to support the Python standard library ``@contextlib.aclosing``
497
+ context manager function.
498
+
499
+ .. versionadded:: 2.0.20
500
+
501
+ """
502
+ await self.close()
503
+
504
+ async def exec_driver_sql(
505
+ self,
506
+ statement: str,
507
+ parameters: Optional[_DBAPIAnyExecuteParams] = None,
508
+ execution_options: Optional[CoreExecuteOptionsParameter] = None,
509
+ ) -> CursorResult[Any]:
510
+ r"""Executes a driver-level SQL string and return buffered
511
+ :class:`_engine.Result`.
512
+
513
+ """
514
+
515
+ result = await greenlet_spawn(
516
+ self._proxied.exec_driver_sql,
517
+ statement,
518
+ parameters,
519
+ execution_options,
520
+ _require_await=True,
521
+ )
522
+
523
+ return await _ensure_sync_result(result, self.exec_driver_sql)
524
+
525
+ @overload
526
+ def stream(
527
+ self,
528
+ statement: TypedReturnsRows[Unpack[_Ts]],
529
+ parameters: Optional[_CoreAnyExecuteParams] = None,
530
+ *,
531
+ execution_options: Optional[CoreExecuteOptionsParameter] = None,
532
+ ) -> GeneratorStartableContext[AsyncResult[Unpack[_Ts]]]: ...
533
+
534
+ @overload
535
+ def stream(
536
+ self,
537
+ statement: Executable,
538
+ parameters: Optional[_CoreAnyExecuteParams] = None,
539
+ *,
540
+ execution_options: Optional[CoreExecuteOptionsParameter] = None,
541
+ ) -> GeneratorStartableContext[AsyncResult[Unpack[TupleAny]]]: ...
542
+
543
+ @asyncstartablecontext
544
+ async def stream(
545
+ self,
546
+ statement: Executable,
547
+ parameters: Optional[_CoreAnyExecuteParams] = None,
548
+ *,
549
+ execution_options: Optional[CoreExecuteOptionsParameter] = None,
550
+ ) -> AsyncIterator[AsyncResult[Unpack[TupleAny]]]:
551
+ """Execute a statement and return an awaitable yielding a
552
+ :class:`_asyncio.AsyncResult` object.
553
+
554
+ E.g.::
555
+
556
+ result = await conn.stream(stmt)
557
+ async for row in result:
558
+ print(f"{row}")
559
+
560
+ The :meth:`.AsyncConnection.stream`
561
+ method supports optional context manager use against the
562
+ :class:`.AsyncResult` object, as in::
563
+
564
+ async with conn.stream(stmt) as result:
565
+ async for row in result:
566
+ print(f"{row}")
567
+
568
+ In the above pattern, the :meth:`.AsyncResult.close` method is
569
+ invoked unconditionally, even if the iterator is interrupted by an
570
+ exception throw. Context manager use remains optional, however,
571
+ and the function may be called in either an ``async with fn():`` or
572
+ ``await fn()`` style.
573
+
574
+ .. versionadded:: 2.0.0b3 added context manager support
575
+
576
+
577
+ :return: an awaitable object that will yield an
578
+ :class:`_asyncio.AsyncResult` object.
579
+
580
+ .. seealso::
581
+
582
+ :meth:`.AsyncConnection.stream_scalars`
583
+
584
+ """
585
+ if not self.dialect.supports_server_side_cursors:
586
+ raise exc.InvalidRequestError(
587
+ "Can't use `stream` or `stream_scalars` with the current "
588
+ "dialect since it does not support server side cursors."
589
+ )
590
+
591
+ result = await greenlet_spawn(
592
+ self._proxied.execute,
593
+ statement,
594
+ parameters,
595
+ execution_options=util.EMPTY_DICT.merge_with(
596
+ execution_options, _stream_results
597
+ ),
598
+ _require_await=True,
599
+ )
600
+ assert result.context._is_server_side
601
+ ar = AsyncResult(result)
602
+ try:
603
+ yield ar
604
+ except GeneratorExit:
605
+ pass
606
+ else:
607
+ task = asyncio.create_task(ar.close())
608
+ await asyncio.shield(task)
609
+
610
+ @overload
611
+ async def execute(
612
+ self,
613
+ statement: TypedReturnsRows[Unpack[_Ts]],
614
+ parameters: Optional[_CoreAnyExecuteParams] = None,
615
+ *,
616
+ execution_options: Optional[CoreExecuteOptionsParameter] = None,
617
+ ) -> CursorResult[Unpack[_Ts]]: ...
618
+
619
+ @overload
620
+ async def execute(
621
+ self,
622
+ statement: Executable,
623
+ parameters: Optional[_CoreAnyExecuteParams] = None,
624
+ *,
625
+ execution_options: Optional[CoreExecuteOptionsParameter] = None,
626
+ ) -> CursorResult[Unpack[TupleAny]]: ...
627
+
628
+ async def execute(
629
+ self,
630
+ statement: Executable,
631
+ parameters: Optional[_CoreAnyExecuteParams] = None,
632
+ *,
633
+ execution_options: Optional[CoreExecuteOptionsParameter] = None,
634
+ ) -> CursorResult[Unpack[TupleAny]]:
635
+ r"""Executes a SQL statement construct and return a buffered
636
+ :class:`_engine.Result`.
637
+
638
+ :param object: The statement to be executed. This is always
639
+ an object that is in both the :class:`_expression.ClauseElement` and
640
+ :class:`_expression.Executable` hierarchies, including:
641
+
642
+ * :class:`_expression.Select`
643
+ * :class:`_expression.Insert`, :class:`_expression.Update`,
644
+ :class:`_expression.Delete`
645
+ * :class:`_expression.TextClause` and
646
+ :class:`_expression.TextualSelect`
647
+ * :class:`_schema.DDL` and objects which inherit from
648
+ :class:`_schema.ExecutableDDLElement`
649
+
650
+ :param parameters: parameters which will be bound into the statement.
651
+ This may be either a dictionary of parameter names to values,
652
+ or a mutable sequence (e.g. a list) of dictionaries. When a
653
+ list of dictionaries is passed, the underlying statement execution
654
+ will make use of the DBAPI ``cursor.executemany()`` method.
655
+ When a single dictionary is passed, the DBAPI ``cursor.execute()``
656
+ method will be used.
657
+
658
+ :param execution_options: optional dictionary of execution options,
659
+ which will be associated with the statement execution. This
660
+ dictionary can provide a subset of the options that are accepted
661
+ by :meth:`_engine.Connection.execution_options`.
662
+
663
+ :return: a :class:`_engine.Result` object.
664
+
665
+ """
666
+ result = await greenlet_spawn(
667
+ self._proxied.execute,
668
+ statement,
669
+ parameters,
670
+ execution_options=execution_options,
671
+ _require_await=True,
672
+ )
673
+ return await _ensure_sync_result(result, self.execute)
674
+
675
+ # special case to handle mypy issue:
676
+ # https://github.com/python/mypy/issues/20651
677
+ @overload
678
+ async def scalar(
679
+ self,
680
+ statement: TypedReturnsRows[Never],
681
+ parameters: Optional[_CoreSingleExecuteParams] = None,
682
+ *,
683
+ execution_options: Optional[CoreExecuteOptionsParameter] = None,
684
+ ) -> Optional[Any]: ...
685
+
686
+ @overload
687
+ async def scalar(
688
+ self,
689
+ statement: TypedReturnsRows[_T],
690
+ parameters: Optional[_CoreSingleExecuteParams] = None,
691
+ *,
692
+ execution_options: Optional[CoreExecuteOptionsParameter] = None,
693
+ ) -> Optional[_T]: ...
694
+
695
+ @overload
696
+ async def scalar(
697
+ self,
698
+ statement: Executable,
699
+ parameters: Optional[_CoreSingleExecuteParams] = None,
700
+ *,
701
+ execution_options: Optional[CoreExecuteOptionsParameter] = None,
702
+ ) -> Any: ...
703
+
704
+ async def scalar(
705
+ self,
706
+ statement: Executable,
707
+ parameters: Optional[_CoreSingleExecuteParams] = None,
708
+ *,
709
+ execution_options: Optional[CoreExecuteOptionsParameter] = None,
710
+ ) -> Any:
711
+ r"""Executes a SQL statement construct and returns a scalar object.
712
+
713
+ This method is shorthand for invoking the
714
+ :meth:`_engine.Result.scalar` method after invoking the
715
+ :meth:`_engine.Connection.execute` method. Parameters are equivalent.
716
+
717
+ :return: a scalar Python value representing the first column of the
718
+ first row returned.
719
+
720
+ """
721
+ result = await self.execute(
722
+ statement, parameters, execution_options=execution_options
723
+ )
724
+ return result.scalar()
725
+
726
+ @overload
727
+ async def scalars(
728
+ self,
729
+ statement: TypedReturnsRows[_T],
730
+ parameters: Optional[_CoreAnyExecuteParams] = None,
731
+ *,
732
+ execution_options: Optional[CoreExecuteOptionsParameter] = None,
733
+ ) -> ScalarResult[_T]: ...
734
+
735
+ @overload
736
+ async def scalars(
737
+ self,
738
+ statement: Executable,
739
+ parameters: Optional[_CoreAnyExecuteParams] = None,
740
+ *,
741
+ execution_options: Optional[CoreExecuteOptionsParameter] = None,
742
+ ) -> ScalarResult[Any]: ...
743
+
744
+ async def scalars(
745
+ self,
746
+ statement: Executable,
747
+ parameters: Optional[_CoreAnyExecuteParams] = None,
748
+ *,
749
+ execution_options: Optional[CoreExecuteOptionsParameter] = None,
750
+ ) -> ScalarResult[Any]:
751
+ r"""Executes a SQL statement construct and returns a scalar objects.
752
+
753
+ This method is shorthand for invoking the
754
+ :meth:`_engine.Result.scalars` method after invoking the
755
+ :meth:`_engine.Connection.execute` method. Parameters are equivalent.
756
+
757
+ :return: a :class:`_engine.ScalarResult` object.
758
+
759
+ .. versionadded:: 1.4.24
760
+
761
+ """
762
+ result = await self.execute(
763
+ statement, parameters, execution_options=execution_options
764
+ )
765
+ return result.scalars()
766
+
767
+ @overload
768
+ def stream_scalars(
769
+ self,
770
+ statement: TypedReturnsRows[_T],
771
+ parameters: Optional[_CoreSingleExecuteParams] = None,
772
+ *,
773
+ execution_options: Optional[CoreExecuteOptionsParameter] = None,
774
+ ) -> GeneratorStartableContext[AsyncScalarResult[_T]]: ...
775
+
776
+ @overload
777
+ def stream_scalars(
778
+ self,
779
+ statement: Executable,
780
+ parameters: Optional[_CoreSingleExecuteParams] = None,
781
+ *,
782
+ execution_options: Optional[CoreExecuteOptionsParameter] = None,
783
+ ) -> GeneratorStartableContext[AsyncScalarResult[Any]]: ...
784
+
785
+ @asyncstartablecontext
786
+ async def stream_scalars(
787
+ self,
788
+ statement: Executable,
789
+ parameters: Optional[_CoreSingleExecuteParams] = None,
790
+ *,
791
+ execution_options: Optional[CoreExecuteOptionsParameter] = None,
792
+ ) -> AsyncIterator[AsyncScalarResult[Any]]:
793
+ r"""Execute a statement and return an awaitable yielding a
794
+ :class:`_asyncio.AsyncScalarResult` object.
795
+
796
+ E.g.::
797
+
798
+ result = await conn.stream_scalars(stmt)
799
+ async for scalar in result:
800
+ print(f"{scalar}")
801
+
802
+ This method is shorthand for invoking the
803
+ :meth:`_engine.AsyncResult.scalars` method after invoking the
804
+ :meth:`_engine.Connection.stream` method. Parameters are equivalent.
805
+
806
+ The :meth:`.AsyncConnection.stream_scalars`
807
+ method supports optional context manager use against the
808
+ :class:`.AsyncScalarResult` object, as in::
809
+
810
+ async with conn.stream_scalars(stmt) as result:
811
+ async for scalar in result:
812
+ print(f"{scalar}")
813
+
814
+ In the above pattern, the :meth:`.AsyncScalarResult.close` method is
815
+ invoked unconditionally, even if the iterator is interrupted by an
816
+ exception throw. Context manager use remains optional, however,
817
+ and the function may be called in either an ``async with fn():`` or
818
+ ``await fn()`` style.
819
+
820
+ .. versionadded:: 2.0.0b3 added context manager support
821
+
822
+ :return: an awaitable object that will yield an
823
+ :class:`_asyncio.AsyncScalarResult` object.
824
+
825
+ .. versionadded:: 1.4.24
826
+
827
+ .. seealso::
828
+
829
+ :meth:`.AsyncConnection.stream`
830
+
831
+ """
832
+
833
+ async with self.stream(
834
+ statement, parameters, execution_options=execution_options
835
+ ) as result:
836
+ yield result.scalars()
837
+
838
+ async def run_sync(
839
+ self,
840
+ fn: Callable[Concatenate[Connection, _P], _T],
841
+ *arg: _P.args,
842
+ **kw: _P.kwargs,
843
+ ) -> _T:
844
+ '''Invoke the given synchronous (i.e. not async) callable,
845
+ passing a synchronous-style :class:`_engine.Connection` as the first
846
+ argument.
847
+
848
+ This method allows traditional synchronous SQLAlchemy functions to
849
+ run within the context of an asyncio application.
850
+
851
+ E.g.::
852
+
853
+ def do_something_with_core(conn: Connection, arg1: int, arg2: str) -> str:
854
+ """A synchronous function that does not require awaiting
855
+
856
+ :param conn: a Core SQLAlchemy Connection, used synchronously
857
+
858
+ :return: an optional return value is supported
859
+
860
+ """
861
+ conn.execute(some_table.insert().values(int_col=arg1, str_col=arg2))
862
+ return "success"
863
+
864
+
865
+ async def do_something_async(async_engine: AsyncEngine) -> None:
866
+ """an async function that uses awaiting"""
867
+
868
+ async with async_engine.begin() as async_conn:
869
+ # run do_something_with_core() with a sync-style
870
+ # Connection, proxied into an awaitable
871
+ return_code = await async_conn.run_sync(
872
+ do_something_with_core, 5, "strval"
873
+ )
874
+ print(return_code)
875
+
876
+ This method maintains the asyncio event loop all the way through
877
+ to the database connection by running the given callable in a
878
+ specially instrumented greenlet.
879
+
880
+ The most rudimentary use of :meth:`.AsyncConnection.run_sync` is to
881
+ invoke methods such as :meth:`_schema.MetaData.create_all`, given
882
+ an :class:`.AsyncConnection` that needs to be provided to
883
+ :meth:`_schema.MetaData.create_all` as a :class:`_engine.Connection`
884
+ object::
885
+
886
+ # run metadata.create_all(conn) with a sync-style Connection,
887
+ # proxied into an awaitable
888
+ with async_engine.begin() as conn:
889
+ await conn.run_sync(metadata.create_all)
890
+
891
+ .. note::
892
+
893
+ The provided callable is invoked inline within the asyncio event
894
+ loop, and will block on traditional IO calls. IO within this
895
+ callable should only call into SQLAlchemy's asyncio database
896
+ APIs which will be properly adapted to the greenlet context.
897
+
898
+ .. seealso::
899
+
900
+ :meth:`.AsyncSession.run_sync`
901
+
902
+ :ref:`session_run_sync`
903
+
904
+ ''' # noqa: E501
905
+
906
+ return await greenlet_spawn(
907
+ fn, self._proxied, *arg, _require_await=False, **kw
908
+ )
909
+
910
+ def __await__(self) -> Generator[Any, None, AsyncConnection]:
911
+ return self.start().__await__()
912
+
913
+ async def __aexit__(self, type_: Any, value: Any, traceback: Any) -> None:
914
+ task = asyncio.create_task(self.close())
915
+ await asyncio.shield(task)
916
+
917
+ # START PROXY METHODS AsyncConnection
918
+
919
+ # code within this block is **programmatically,
920
+ # statically generated** by tools/generate_proxy_methods.py
921
+
922
+ @property
923
+ def closed(self) -> Any:
924
+ r"""Return True if this connection is closed.
925
+
926
+ .. container:: class_bases
927
+
928
+ Proxied for the :class:`_engine.Connection` class
929
+ on behalf of the :class:`_asyncio.AsyncConnection` class.
930
+
931
+ """ # noqa: E501
932
+
933
+ return self._proxied.closed
934
+
935
+ @property
936
+ def invalidated(self) -> Any:
937
+ r"""Return True if this connection was invalidated.
938
+
939
+ .. container:: class_bases
940
+
941
+ Proxied for the :class:`_engine.Connection` class
942
+ on behalf of the :class:`_asyncio.AsyncConnection` class.
943
+
944
+ This does not indicate whether or not the connection was
945
+ invalidated at the pool level, however
946
+
947
+
948
+ """ # noqa: E501
949
+
950
+ return self._proxied.invalidated
951
+
952
+ @property
953
+ def dialect(self) -> Dialect:
954
+ r"""Proxy for the :attr:`_engine.Connection.dialect` attribute
955
+ on behalf of the :class:`_asyncio.AsyncConnection` class.
956
+
957
+ """ # noqa: E501
958
+
959
+ return self._proxied.dialect
960
+
961
+ @dialect.setter
962
+ def dialect(self, attr: Dialect) -> None:
963
+ self._proxied.dialect = attr
964
+
965
+ @property
966
+ def default_isolation_level(self) -> Any:
967
+ r"""The initial-connection time isolation level associated with the
968
+ :class:`_engine.Dialect` in use.
969
+
970
+ .. container:: class_bases
971
+
972
+ Proxied for the :class:`_engine.Connection` class
973
+ on behalf of the :class:`_asyncio.AsyncConnection` class.
974
+
975
+ This value is independent of the
976
+ :paramref:`.Connection.execution_options.isolation_level` and
977
+ :paramref:`.Engine.execution_options.isolation_level` execution
978
+ options, and is determined by the :class:`_engine.Dialect` when the
979
+ first connection is created, by performing a SQL query against the
980
+ database for the current isolation level before any additional commands
981
+ have been emitted.
982
+
983
+ Calling this accessor does not invoke any new SQL queries.
984
+
985
+ .. seealso::
986
+
987
+ :meth:`_engine.Connection.get_isolation_level`
988
+ - view current actual isolation level
989
+
990
+ :paramref:`_sa.create_engine.isolation_level`
991
+ - set per :class:`_engine.Engine` isolation level
992
+
993
+ :paramref:`.Connection.execution_options.isolation_level`
994
+ - set per :class:`_engine.Connection` isolation level
995
+
996
+
997
+ """ # noqa: E501
998
+
999
+ return self._proxied.default_isolation_level
1000
+
1001
+ # END PROXY METHODS AsyncConnection
1002
+
1003
+
1004
+ @util.create_proxy_methods(
1005
+ Engine,
1006
+ ":class:`_engine.Engine`",
1007
+ ":class:`_asyncio.AsyncEngine`",
1008
+ classmethods=[],
1009
+ methods=[
1010
+ "clear_compiled_cache",
1011
+ "update_execution_options",
1012
+ "get_execution_options",
1013
+ ],
1014
+ attributes=["url", "pool", "dialect", "engine", "name", "driver", "echo"],
1015
+ )
1016
+ # "Class has incompatible disjoint bases" - no idea
1017
+ class AsyncEngine(ProxyComparable[Engine], AsyncConnectable): # type: ignore[misc] # noqa:E501
1018
+ """An asyncio proxy for a :class:`_engine.Engine`.
1019
+
1020
+ :class:`_asyncio.AsyncEngine` is acquired using the
1021
+ :func:`_asyncio.create_async_engine` function::
1022
+
1023
+ from sqlalchemy.ext.asyncio import create_async_engine
1024
+
1025
+ engine = create_async_engine("postgresql+asyncpg://user:pass@host/dbname")
1026
+
1027
+ .. versionadded:: 1.4
1028
+
1029
+ """ # noqa
1030
+
1031
+ # AsyncEngine is a thin proxy; no state should be added here
1032
+ # that is not retrievable from the "sync" engine / connection, e.g.
1033
+ # current transaction, info, etc. It should be possible to
1034
+ # create a new AsyncEngine that matches this one given only the
1035
+ # "sync" elements.
1036
+ __slots__ = "sync_engine"
1037
+
1038
+ _connection_cls: Type[AsyncConnection] = AsyncConnection
1039
+
1040
+ sync_engine: Engine
1041
+ """Reference to the sync-style :class:`_engine.Engine` this
1042
+ :class:`_asyncio.AsyncEngine` proxies requests towards.
1043
+
1044
+ This instance can be used as an event target.
1045
+
1046
+ .. seealso::
1047
+
1048
+ :ref:`asyncio_events`
1049
+ """
1050
+
1051
+ def __init__(self, sync_engine: Engine):
1052
+ if not sync_engine.dialect.is_async:
1053
+ raise exc.InvalidRequestError(
1054
+ "The asyncio extension requires an async driver to be used. "
1055
+ f"The loaded {sync_engine.dialect.driver!r} is not async."
1056
+ )
1057
+ self.sync_engine = self._assign_proxied(sync_engine)
1058
+
1059
+ @util.ro_non_memoized_property
1060
+ def _proxied(self) -> Engine:
1061
+ return self.sync_engine
1062
+
1063
+ @classmethod
1064
+ def _regenerate_proxy_for_target(
1065
+ cls, target: Engine, **additional_kw: Any # noqa: U100
1066
+ ) -> AsyncEngine:
1067
+ return AsyncEngine(target)
1068
+
1069
+ @contextlib.asynccontextmanager
1070
+ async def begin(self) -> AsyncIterator[AsyncConnection]:
1071
+ """Return a context manager which when entered will deliver an
1072
+ :class:`_asyncio.AsyncConnection` with an
1073
+ :class:`_asyncio.AsyncTransaction` established.
1074
+
1075
+ E.g.::
1076
+
1077
+ async with async_engine.begin() as conn:
1078
+ await conn.execute(
1079
+ text("insert into table (x, y, z) values (1, 2, 3)")
1080
+ )
1081
+ await conn.execute(text("my_special_procedure(5)"))
1082
+
1083
+ """
1084
+ conn = self.connect()
1085
+
1086
+ async with conn:
1087
+ async with conn.begin():
1088
+ yield conn
1089
+
1090
+ def connect(self) -> AsyncConnection:
1091
+ """Return an :class:`_asyncio.AsyncConnection` object.
1092
+
1093
+ The :class:`_asyncio.AsyncConnection` will procure a database
1094
+ connection from the underlying connection pool when it is entered
1095
+ as an async context manager::
1096
+
1097
+ async with async_engine.connect() as conn:
1098
+ result = await conn.execute(select(user_table))
1099
+
1100
+ The :class:`_asyncio.AsyncConnection` may also be started outside of a
1101
+ context manager by invoking its :meth:`_asyncio.AsyncConnection.start`
1102
+ method.
1103
+
1104
+ """
1105
+
1106
+ return self._connection_cls(self)
1107
+
1108
+ async def raw_connection(self) -> PoolProxiedConnection:
1109
+ """Return a "raw" DBAPI connection from the connection pool.
1110
+
1111
+ .. seealso::
1112
+
1113
+ :ref:`dbapi_connections`
1114
+
1115
+ """
1116
+ return await greenlet_spawn(self.sync_engine.raw_connection)
1117
+
1118
+ @overload
1119
+ def execution_options(
1120
+ self,
1121
+ *,
1122
+ compiled_cache: Optional[CompiledCacheType] = ...,
1123
+ logging_token: str = ...,
1124
+ isolation_level: IsolationLevel = ...,
1125
+ insertmanyvalues_page_size: int = ...,
1126
+ schema_translate_map: Optional[SchemaTranslateMapType] = ...,
1127
+ **opt: Any,
1128
+ ) -> AsyncEngine: ...
1129
+
1130
+ @overload
1131
+ def execution_options(self, **opt: Any) -> AsyncEngine: ...
1132
+
1133
+ def execution_options(self, **opt: Any) -> AsyncEngine:
1134
+ """Return a new :class:`_asyncio.AsyncEngine` that will provide
1135
+ :class:`_asyncio.AsyncConnection` objects with the given execution
1136
+ options.
1137
+
1138
+ Proxied from :meth:`_engine.Engine.execution_options`. See that
1139
+ method for details.
1140
+
1141
+ """
1142
+
1143
+ return AsyncEngine(self.sync_engine.execution_options(**opt))
1144
+
1145
+ async def dispose(self, close: bool = True) -> None:
1146
+ """Dispose of the connection pool used by this
1147
+ :class:`_asyncio.AsyncEngine`.
1148
+
1149
+ :param close: if left at its default of ``True``, has the
1150
+ effect of fully closing all **currently checked in**
1151
+ database connections. Connections that are still checked out
1152
+ will **not** be closed, however they will no longer be associated
1153
+ with this :class:`_engine.Engine`,
1154
+ so when they are closed individually, eventually the
1155
+ :class:`_pool.Pool` which they are associated with will
1156
+ be garbage collected and they will be closed out fully, if
1157
+ not already closed on checkin.
1158
+
1159
+ If set to ``False``, the previous connection pool is de-referenced,
1160
+ and otherwise not touched in any way.
1161
+
1162
+ .. seealso::
1163
+
1164
+ :meth:`_engine.Engine.dispose`
1165
+
1166
+ """
1167
+
1168
+ await greenlet_spawn(self.sync_engine.dispose, close=close)
1169
+
1170
+ # START PROXY METHODS AsyncEngine
1171
+
1172
+ # code within this block is **programmatically,
1173
+ # statically generated** by tools/generate_proxy_methods.py
1174
+
1175
+ def clear_compiled_cache(self) -> None:
1176
+ r"""Clear the compiled cache associated with the dialect.
1177
+
1178
+ .. container:: class_bases
1179
+
1180
+ Proxied for the :class:`_engine.Engine` class on
1181
+ behalf of the :class:`_asyncio.AsyncEngine` class.
1182
+
1183
+ This applies **only** to the built-in cache that is established
1184
+ via the :paramref:`_engine.create_engine.query_cache_size` parameter.
1185
+ It will not impact any dictionary caches that were passed via the
1186
+ :paramref:`.Connection.execution_options.compiled_cache` parameter.
1187
+
1188
+ .. versionadded:: 1.4
1189
+
1190
+
1191
+ """ # noqa: E501
1192
+
1193
+ return self._proxied.clear_compiled_cache()
1194
+
1195
+ def update_execution_options(self, **opt: Any) -> None:
1196
+ r"""Update the default execution_options dictionary
1197
+ of this :class:`_engine.Engine`.
1198
+
1199
+ .. container:: class_bases
1200
+
1201
+ Proxied for the :class:`_engine.Engine` class on
1202
+ behalf of the :class:`_asyncio.AsyncEngine` class.
1203
+
1204
+ The given keys/values in \**opt are added to the
1205
+ default execution options that will be used for
1206
+ all connections. The initial contents of this dictionary
1207
+ can be sent via the ``execution_options`` parameter
1208
+ to :func:`_sa.create_engine`.
1209
+
1210
+ .. seealso::
1211
+
1212
+ :meth:`_engine.Connection.execution_options`
1213
+
1214
+ :meth:`_engine.Engine.execution_options`
1215
+
1216
+
1217
+ """ # noqa: E501
1218
+
1219
+ return self._proxied.update_execution_options(**opt)
1220
+
1221
+ def get_execution_options(self) -> _ExecuteOptions:
1222
+ r"""Get the non-SQL options which will take effect during execution.
1223
+
1224
+ .. container:: class_bases
1225
+
1226
+ Proxied for the :class:`_engine.Engine` class on
1227
+ behalf of the :class:`_asyncio.AsyncEngine` class.
1228
+
1229
+ .. seealso::
1230
+
1231
+ :meth:`_engine.Engine.execution_options`
1232
+
1233
+ """ # noqa: E501
1234
+
1235
+ return self._proxied.get_execution_options()
1236
+
1237
+ @property
1238
+ def url(self) -> URL:
1239
+ r"""Proxy for the :attr:`_engine.Engine.url` attribute
1240
+ on behalf of the :class:`_asyncio.AsyncEngine` class.
1241
+
1242
+ """ # noqa: E501
1243
+
1244
+ return self._proxied.url
1245
+
1246
+ @url.setter
1247
+ def url(self, attr: URL) -> None:
1248
+ self._proxied.url = attr
1249
+
1250
+ @property
1251
+ def pool(self) -> Pool:
1252
+ r"""Proxy for the :attr:`_engine.Engine.pool` attribute
1253
+ on behalf of the :class:`_asyncio.AsyncEngine` class.
1254
+
1255
+ """ # noqa: E501
1256
+
1257
+ return self._proxied.pool
1258
+
1259
+ @pool.setter
1260
+ def pool(self, attr: Pool) -> None:
1261
+ self._proxied.pool = attr
1262
+
1263
+ @property
1264
+ def dialect(self) -> Dialect:
1265
+ r"""Proxy for the :attr:`_engine.Engine.dialect` attribute
1266
+ on behalf of the :class:`_asyncio.AsyncEngine` class.
1267
+
1268
+ """ # noqa: E501
1269
+
1270
+ return self._proxied.dialect
1271
+
1272
+ @dialect.setter
1273
+ def dialect(self, attr: Dialect) -> None:
1274
+ self._proxied.dialect = attr
1275
+
1276
+ @property
1277
+ def engine(self) -> Any:
1278
+ r"""Returns this :class:`.Engine`.
1279
+
1280
+ .. container:: class_bases
1281
+
1282
+ Proxied for the :class:`_engine.Engine` class
1283
+ on behalf of the :class:`_asyncio.AsyncEngine` class.
1284
+
1285
+ Used for legacy schemes that accept :class:`.Connection` /
1286
+ :class:`.Engine` objects within the same variable.
1287
+
1288
+
1289
+ """ # noqa: E501
1290
+
1291
+ return self._proxied.engine
1292
+
1293
+ @property
1294
+ def name(self) -> Any:
1295
+ r"""String name of the :class:`~sqlalchemy.engine.interfaces.Dialect`
1296
+ in use by this :class:`Engine`.
1297
+
1298
+ .. container:: class_bases
1299
+
1300
+ Proxied for the :class:`_engine.Engine` class
1301
+ on behalf of the :class:`_asyncio.AsyncEngine` class.
1302
+
1303
+
1304
+ """ # noqa: E501
1305
+
1306
+ return self._proxied.name
1307
+
1308
+ @property
1309
+ def driver(self) -> Any:
1310
+ r"""Driver name of the :class:`~sqlalchemy.engine.interfaces.Dialect`
1311
+ in use by this :class:`Engine`.
1312
+
1313
+ .. container:: class_bases
1314
+
1315
+ Proxied for the :class:`_engine.Engine` class
1316
+ on behalf of the :class:`_asyncio.AsyncEngine` class.
1317
+
1318
+
1319
+ """ # noqa: E501
1320
+
1321
+ return self._proxied.driver
1322
+
1323
+ @property
1324
+ def echo(self) -> Any:
1325
+ r"""When ``True``, enable log output for this element.
1326
+
1327
+ .. container:: class_bases
1328
+
1329
+ Proxied for the :class:`_engine.Engine` class
1330
+ on behalf of the :class:`_asyncio.AsyncEngine` class.
1331
+
1332
+ This has the effect of setting the Python logging level for the namespace
1333
+ of this element's class and object reference. A value of boolean ``True``
1334
+ indicates that the loglevel ``logging.INFO`` will be set for the logger,
1335
+ whereas the string value ``debug`` will set the loglevel to
1336
+ ``logging.DEBUG``.
1337
+
1338
+ """ # noqa: E501
1339
+
1340
+ return self._proxied.echo
1341
+
1342
+ @echo.setter
1343
+ def echo(self, attr: Any) -> None:
1344
+ self._proxied.echo = attr
1345
+
1346
+ # END PROXY METHODS AsyncEngine
1347
+
1348
+
1349
+ class AsyncTransaction(
1350
+ ProxyComparable[Transaction], StartableContext["AsyncTransaction"]
1351
+ ):
1352
+ """An asyncio proxy for a :class:`_engine.Transaction`."""
1353
+
1354
+ __slots__ = ("connection", "sync_transaction", "nested")
1355
+
1356
+ sync_transaction: Optional[Transaction]
1357
+ connection: AsyncConnection
1358
+ nested: bool
1359
+
1360
+ def __init__(self, connection: AsyncConnection, nested: bool = False):
1361
+ self.connection = connection
1362
+ self.sync_transaction = None
1363
+ self.nested = nested
1364
+
1365
+ @classmethod
1366
+ def _regenerate_proxy_for_target(
1367
+ cls, target: Transaction, **additional_kw: Any # noqa: U100
1368
+ ) -> AsyncTransaction:
1369
+ sync_connection = target.connection
1370
+ sync_transaction = target
1371
+ nested = isinstance(target, NestedTransaction)
1372
+
1373
+ async_connection = AsyncConnection._retrieve_proxy_for_target(
1374
+ sync_connection
1375
+ )
1376
+ assert async_connection is not None
1377
+
1378
+ obj = cls.__new__(cls)
1379
+ obj.connection = async_connection
1380
+ obj.sync_transaction = obj._assign_proxied(sync_transaction)
1381
+ obj.nested = nested
1382
+ return obj
1383
+
1384
+ @util.ro_non_memoized_property
1385
+ def _proxied(self) -> Transaction:
1386
+ if not self.sync_transaction:
1387
+ self._raise_for_not_started()
1388
+ return self.sync_transaction
1389
+
1390
+ @property
1391
+ def is_valid(self) -> bool:
1392
+ return self._proxied.is_valid
1393
+
1394
+ @property
1395
+ def is_active(self) -> bool:
1396
+ return self._proxied.is_active
1397
+
1398
+ async def close(self) -> None:
1399
+ """Close this :class:`.AsyncTransaction`.
1400
+
1401
+ If this transaction is the base transaction in a begin/commit
1402
+ nesting, the transaction will rollback(). Otherwise, the
1403
+ method returns.
1404
+
1405
+ This is used to cancel a Transaction without affecting the scope of
1406
+ an enclosing transaction.
1407
+
1408
+ """
1409
+ await greenlet_spawn(self._proxied.close)
1410
+
1411
+ async def rollback(self) -> None:
1412
+ """Roll back this :class:`.AsyncTransaction`."""
1413
+ await greenlet_spawn(self._proxied.rollback)
1414
+
1415
+ async def commit(self) -> None:
1416
+ """Commit this :class:`.AsyncTransaction`."""
1417
+
1418
+ await greenlet_spawn(self._proxied.commit)
1419
+
1420
+ async def start(self, is_ctxmanager: bool = False) -> AsyncTransaction:
1421
+ """Start this :class:`_asyncio.AsyncTransaction` object's context
1422
+ outside of using a Python ``with:`` block.
1423
+
1424
+ """
1425
+
1426
+ self.sync_transaction = self._assign_proxied(
1427
+ await greenlet_spawn(
1428
+ self.connection._proxied.begin_nested
1429
+ if self.nested
1430
+ else self.connection._proxied.begin
1431
+ )
1432
+ )
1433
+ if is_ctxmanager:
1434
+ self.sync_transaction.__enter__()
1435
+ return self
1436
+
1437
+ async def __aexit__(self, type_: Any, value: Any, traceback: Any) -> None:
1438
+ await greenlet_spawn(self._proxied.__exit__, type_, value, traceback)
1439
+
1440
+
1441
+ @overload
1442
+ def _get_sync_engine_or_connection(async_engine: AsyncEngine) -> Engine: ...
1443
+
1444
+
1445
+ @overload
1446
+ def _get_sync_engine_or_connection(
1447
+ async_engine: AsyncConnection,
1448
+ ) -> Connection: ...
1449
+
1450
+
1451
+ def _get_sync_engine_or_connection(
1452
+ async_engine: Union[AsyncEngine, AsyncConnection],
1453
+ ) -> Union[Engine, Connection]:
1454
+ if isinstance(async_engine, AsyncConnection):
1455
+ return async_engine._proxied
1456
+
1457
+ try:
1458
+ return async_engine.sync_engine
1459
+ except AttributeError as e:
1460
+ raise exc.ArgumentError(
1461
+ "AsyncEngine expected, got %r" % async_engine
1462
+ ) from e
1463
+
1464
+
1465
+ @inspection._inspects(AsyncConnection)
1466
+ def _no_insp_for_async_conn_yet(
1467
+ subject: AsyncConnection, # noqa: U100
1468
+ ) -> NoReturn:
1469
+ raise exc.NoInspectionAvailable(
1470
+ "Inspection on an AsyncConnection is currently not supported. "
1471
+ "Please use ``run_sync`` to pass a callable where it's possible "
1472
+ "to call ``inspect`` on the passed connection.",
1473
+ code="xd3s",
1474
+ )
1475
+
1476
+
1477
+ @inspection._inspects(AsyncEngine)
1478
+ def _no_insp_for_async_engine_xyet(
1479
+ subject: AsyncEngine, # noqa: U100
1480
+ ) -> NoReturn:
1481
+ raise exc.NoInspectionAvailable(
1482
+ "Inspection on an AsyncEngine is currently not supported. "
1483
+ "Please obtain a connection then use ``conn.run_sync`` to pass a "
1484
+ "callable where it's possible to call ``inspect`` on the "
1485
+ "passed connection.",
1486
+ code="xd3s",
1487
+ )