SQLAlchemy 2.0.36__cp313-cp313-win_amd64.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 (273) hide show
  1. SQLAlchemy-2.0.36.dist-info/LICENSE +19 -0
  2. SQLAlchemy-2.0.36.dist-info/METADATA +243 -0
  3. SQLAlchemy-2.0.36.dist-info/RECORD +273 -0
  4. SQLAlchemy-2.0.36.dist-info/WHEEL +5 -0
  5. SQLAlchemy-2.0.36.dist-info/top_level.txt +1 -0
  6. sqlalchemy/__init__.py +294 -0
  7. sqlalchemy/connectors/__init__.py +18 -0
  8. sqlalchemy/connectors/aioodbc.py +174 -0
  9. sqlalchemy/connectors/asyncio.py +213 -0
  10. sqlalchemy/connectors/pyodbc.py +249 -0
  11. sqlalchemy/cyextension/__init__.py +6 -0
  12. sqlalchemy/cyextension/collections.cp313-win_amd64.pyd +0 -0
  13. sqlalchemy/cyextension/collections.pyx +409 -0
  14. sqlalchemy/cyextension/immutabledict.cp313-win_amd64.pyd +0 -0
  15. sqlalchemy/cyextension/immutabledict.pxd +8 -0
  16. sqlalchemy/cyextension/immutabledict.pyx +133 -0
  17. sqlalchemy/cyextension/processors.cp313-win_amd64.pyd +0 -0
  18. sqlalchemy/cyextension/processors.pyx +68 -0
  19. sqlalchemy/cyextension/resultproxy.cp313-win_amd64.pyd +0 -0
  20. sqlalchemy/cyextension/resultproxy.pyx +102 -0
  21. sqlalchemy/cyextension/util.cp313-win_amd64.pyd +0 -0
  22. sqlalchemy/cyextension/util.pyx +91 -0
  23. sqlalchemy/dialects/__init__.py +61 -0
  24. sqlalchemy/dialects/_typing.py +25 -0
  25. sqlalchemy/dialects/mssql/__init__.py +88 -0
  26. sqlalchemy/dialects/mssql/aioodbc.py +64 -0
  27. sqlalchemy/dialects/mssql/base.py +4010 -0
  28. sqlalchemy/dialects/mssql/information_schema.py +254 -0
  29. sqlalchemy/dialects/mssql/json.py +133 -0
  30. sqlalchemy/dialects/mssql/provision.py +162 -0
  31. sqlalchemy/dialects/mssql/pymssql.py +126 -0
  32. sqlalchemy/dialects/mssql/pyodbc.py +745 -0
  33. sqlalchemy/dialects/mysql/__init__.py +101 -0
  34. sqlalchemy/dialects/mysql/aiomysql.py +333 -0
  35. sqlalchemy/dialects/mysql/asyncmy.py +337 -0
  36. sqlalchemy/dialects/mysql/base.py +3494 -0
  37. sqlalchemy/dialects/mysql/cymysql.py +84 -0
  38. sqlalchemy/dialects/mysql/dml.py +219 -0
  39. sqlalchemy/dialects/mysql/enumerated.py +244 -0
  40. sqlalchemy/dialects/mysql/expression.py +141 -0
  41. sqlalchemy/dialects/mysql/json.py +81 -0
  42. sqlalchemy/dialects/mysql/mariadb.py +32 -0
  43. sqlalchemy/dialects/mysql/mariadbconnector.py +277 -0
  44. sqlalchemy/dialects/mysql/mysqlconnector.py +180 -0
  45. sqlalchemy/dialects/mysql/mysqldb.py +303 -0
  46. sqlalchemy/dialects/mysql/provision.py +110 -0
  47. sqlalchemy/dialects/mysql/pymysql.py +137 -0
  48. sqlalchemy/dialects/mysql/pyodbc.py +138 -0
  49. sqlalchemy/dialects/mysql/reflection.py +677 -0
  50. sqlalchemy/dialects/mysql/reserved_words.py +571 -0
  51. sqlalchemy/dialects/mysql/types.py +774 -0
  52. sqlalchemy/dialects/oracle/__init__.py +67 -0
  53. sqlalchemy/dialects/oracle/base.py +3271 -0
  54. sqlalchemy/dialects/oracle/cx_oracle.py +1483 -0
  55. sqlalchemy/dialects/oracle/dictionary.py +507 -0
  56. sqlalchemy/dialects/oracle/oracledb.py +431 -0
  57. sqlalchemy/dialects/oracle/provision.py +220 -0
  58. sqlalchemy/dialects/oracle/types.py +287 -0
  59. sqlalchemy/dialects/postgresql/__init__.py +167 -0
  60. sqlalchemy/dialects/postgresql/_psycopg_common.py +187 -0
  61. sqlalchemy/dialects/postgresql/array.py +425 -0
  62. sqlalchemy/dialects/postgresql/asyncpg.py +1274 -0
  63. sqlalchemy/dialects/postgresql/base.py +5008 -0
  64. sqlalchemy/dialects/postgresql/dml.py +310 -0
  65. sqlalchemy/dialects/postgresql/ext.py +496 -0
  66. sqlalchemy/dialects/postgresql/hstore.py +397 -0
  67. sqlalchemy/dialects/postgresql/json.py +333 -0
  68. sqlalchemy/dialects/postgresql/named_types.py +509 -0
  69. sqlalchemy/dialects/postgresql/operators.py +129 -0
  70. sqlalchemy/dialects/postgresql/pg8000.py +662 -0
  71. sqlalchemy/dialects/postgresql/pg_catalog.py +300 -0
  72. sqlalchemy/dialects/postgresql/provision.py +175 -0
  73. sqlalchemy/dialects/postgresql/psycopg.py +772 -0
  74. sqlalchemy/dialects/postgresql/psycopg2.py +886 -0
  75. sqlalchemy/dialects/postgresql/psycopg2cffi.py +61 -0
  76. sqlalchemy/dialects/postgresql/ranges.py +1029 -0
  77. sqlalchemy/dialects/postgresql/types.py +303 -0
  78. sqlalchemy/dialects/sqlite/__init__.py +57 -0
  79. sqlalchemy/dialects/sqlite/aiosqlite.py +396 -0
  80. sqlalchemy/dialects/sqlite/base.py +2805 -0
  81. sqlalchemy/dialects/sqlite/dml.py +240 -0
  82. sqlalchemy/dialects/sqlite/json.py +92 -0
  83. sqlalchemy/dialects/sqlite/provision.py +198 -0
  84. sqlalchemy/dialects/sqlite/pysqlcipher.py +155 -0
  85. sqlalchemy/dialects/sqlite/pysqlite.py +756 -0
  86. sqlalchemy/dialects/type_migration_guidelines.txt +145 -0
  87. sqlalchemy/engine/__init__.py +62 -0
  88. sqlalchemy/engine/_py_processors.py +136 -0
  89. sqlalchemy/engine/_py_row.py +128 -0
  90. sqlalchemy/engine/_py_util.py +74 -0
  91. sqlalchemy/engine/base.py +3375 -0
  92. sqlalchemy/engine/characteristics.py +155 -0
  93. sqlalchemy/engine/create.py +875 -0
  94. sqlalchemy/engine/cursor.py +2181 -0
  95. sqlalchemy/engine/default.py +2365 -0
  96. sqlalchemy/engine/events.py +951 -0
  97. sqlalchemy/engine/interfaces.py +3403 -0
  98. sqlalchemy/engine/mock.py +131 -0
  99. sqlalchemy/engine/processors.py +61 -0
  100. sqlalchemy/engine/reflection.py +2098 -0
  101. sqlalchemy/engine/result.py +2382 -0
  102. sqlalchemy/engine/row.py +401 -0
  103. sqlalchemy/engine/strategies.py +19 -0
  104. sqlalchemy/engine/url.py +910 -0
  105. sqlalchemy/engine/util.py +167 -0
  106. sqlalchemy/event/__init__.py +25 -0
  107. sqlalchemy/event/api.py +225 -0
  108. sqlalchemy/event/attr.py +655 -0
  109. sqlalchemy/event/base.py +470 -0
  110. sqlalchemy/event/legacy.py +246 -0
  111. sqlalchemy/event/registry.py +386 -0
  112. sqlalchemy/events.py +17 -0
  113. sqlalchemy/exc.py +830 -0
  114. sqlalchemy/ext/__init__.py +11 -0
  115. sqlalchemy/ext/associationproxy.py +2013 -0
  116. sqlalchemy/ext/asyncio/__init__.py +25 -0
  117. sqlalchemy/ext/asyncio/base.py +279 -0
  118. sqlalchemy/ext/asyncio/engine.py +1466 -0
  119. sqlalchemy/ext/asyncio/exc.py +21 -0
  120. sqlalchemy/ext/asyncio/result.py +961 -0
  121. sqlalchemy/ext/asyncio/scoping.py +1614 -0
  122. sqlalchemy/ext/asyncio/session.py +1936 -0
  123. sqlalchemy/ext/automap.py +1691 -0
  124. sqlalchemy/ext/baked.py +574 -0
  125. sqlalchemy/ext/compiler.py +570 -0
  126. sqlalchemy/ext/declarative/__init__.py +65 -0
  127. sqlalchemy/ext/declarative/extensions.py +548 -0
  128. sqlalchemy/ext/horizontal_shard.py +481 -0
  129. sqlalchemy/ext/hybrid.py +1514 -0
  130. sqlalchemy/ext/indexable.py +341 -0
  131. sqlalchemy/ext/instrumentation.py +450 -0
  132. sqlalchemy/ext/mutable.py +1073 -0
  133. sqlalchemy/ext/mypy/__init__.py +6 -0
  134. sqlalchemy/ext/mypy/apply.py +320 -0
  135. sqlalchemy/ext/mypy/decl_class.py +515 -0
  136. sqlalchemy/ext/mypy/infer.py +590 -0
  137. sqlalchemy/ext/mypy/names.py +335 -0
  138. sqlalchemy/ext/mypy/plugin.py +303 -0
  139. sqlalchemy/ext/mypy/util.py +357 -0
  140. sqlalchemy/ext/orderinglist.py +416 -0
  141. sqlalchemy/ext/serializer.py +181 -0
  142. sqlalchemy/future/__init__.py +16 -0
  143. sqlalchemy/future/engine.py +15 -0
  144. sqlalchemy/inspection.py +174 -0
  145. sqlalchemy/log.py +288 -0
  146. sqlalchemy/orm/__init__.py +170 -0
  147. sqlalchemy/orm/_orm_constructors.py +2571 -0
  148. sqlalchemy/orm/_typing.py +179 -0
  149. sqlalchemy/orm/attributes.py +2835 -0
  150. sqlalchemy/orm/base.py +973 -0
  151. sqlalchemy/orm/bulk_persistence.py +2123 -0
  152. sqlalchemy/orm/clsregistry.py +571 -0
  153. sqlalchemy/orm/collections.py +1620 -0
  154. sqlalchemy/orm/context.py +3268 -0
  155. sqlalchemy/orm/decl_api.py +1883 -0
  156. sqlalchemy/orm/decl_base.py +2190 -0
  157. sqlalchemy/orm/dependency.py +1304 -0
  158. sqlalchemy/orm/descriptor_props.py +1076 -0
  159. sqlalchemy/orm/dynamic.py +300 -0
  160. sqlalchemy/orm/evaluator.py +379 -0
  161. sqlalchemy/orm/events.py +3261 -0
  162. sqlalchemy/orm/exc.py +228 -0
  163. sqlalchemy/orm/identity.py +302 -0
  164. sqlalchemy/orm/instrumentation.py +754 -0
  165. sqlalchemy/orm/interfaces.py +1474 -0
  166. sqlalchemy/orm/loading.py +1682 -0
  167. sqlalchemy/orm/mapped_collection.py +557 -0
  168. sqlalchemy/orm/mapper.py +4432 -0
  169. sqlalchemy/orm/path_registry.py +811 -0
  170. sqlalchemy/orm/persistence.py +1782 -0
  171. sqlalchemy/orm/properties.py +886 -0
  172. sqlalchemy/orm/query.py +3396 -0
  173. sqlalchemy/orm/relationships.py +3500 -0
  174. sqlalchemy/orm/scoping.py +2165 -0
  175. sqlalchemy/orm/session.py +5301 -0
  176. sqlalchemy/orm/state.py +1143 -0
  177. sqlalchemy/orm/state_changes.py +198 -0
  178. sqlalchemy/orm/strategies.py +3473 -0
  179. sqlalchemy/orm/strategy_options.py +2569 -0
  180. sqlalchemy/orm/sync.py +164 -0
  181. sqlalchemy/orm/unitofwork.py +796 -0
  182. sqlalchemy/orm/util.py +2424 -0
  183. sqlalchemy/orm/writeonly.py +678 -0
  184. sqlalchemy/pool/__init__.py +44 -0
  185. sqlalchemy/pool/base.py +1515 -0
  186. sqlalchemy/pool/events.py +370 -0
  187. sqlalchemy/pool/impl.py +581 -0
  188. sqlalchemy/py.typed +0 -0
  189. sqlalchemy/schema.py +70 -0
  190. sqlalchemy/sql/__init__.py +145 -0
  191. sqlalchemy/sql/_dml_constructors.py +140 -0
  192. sqlalchemy/sql/_elements_constructors.py +1850 -0
  193. sqlalchemy/sql/_orm_types.py +20 -0
  194. sqlalchemy/sql/_py_util.py +75 -0
  195. sqlalchemy/sql/_selectable_constructors.py +635 -0
  196. sqlalchemy/sql/_typing.py +460 -0
  197. sqlalchemy/sql/annotation.py +585 -0
  198. sqlalchemy/sql/base.py +2185 -0
  199. sqlalchemy/sql/cache_key.py +1057 -0
  200. sqlalchemy/sql/coercions.py +1405 -0
  201. sqlalchemy/sql/compiler.py +7818 -0
  202. sqlalchemy/sql/crud.py +1669 -0
  203. sqlalchemy/sql/ddl.py +1378 -0
  204. sqlalchemy/sql/default_comparator.py +552 -0
  205. sqlalchemy/sql/dml.py +1817 -0
  206. sqlalchemy/sql/elements.py +5499 -0
  207. sqlalchemy/sql/events.py +455 -0
  208. sqlalchemy/sql/expression.py +162 -0
  209. sqlalchemy/sql/functions.py +2055 -0
  210. sqlalchemy/sql/lambdas.py +1449 -0
  211. sqlalchemy/sql/naming.py +212 -0
  212. sqlalchemy/sql/operators.py +2579 -0
  213. sqlalchemy/sql/roles.py +323 -0
  214. sqlalchemy/sql/schema.py +6158 -0
  215. sqlalchemy/sql/selectable.py +7004 -0
  216. sqlalchemy/sql/sqltypes.py +3827 -0
  217. sqlalchemy/sql/traversals.py +1024 -0
  218. sqlalchemy/sql/type_api.py +2339 -0
  219. sqlalchemy/sql/util.py +1486 -0
  220. sqlalchemy/sql/visitors.py +1165 -0
  221. sqlalchemy/testing/__init__.py +96 -0
  222. sqlalchemy/testing/assertions.py +989 -0
  223. sqlalchemy/testing/assertsql.py +516 -0
  224. sqlalchemy/testing/asyncio.py +135 -0
  225. sqlalchemy/testing/config.py +427 -0
  226. sqlalchemy/testing/engines.py +472 -0
  227. sqlalchemy/testing/entities.py +117 -0
  228. sqlalchemy/testing/exclusions.py +435 -0
  229. sqlalchemy/testing/fixtures/__init__.py +28 -0
  230. sqlalchemy/testing/fixtures/base.py +366 -0
  231. sqlalchemy/testing/fixtures/mypy.py +312 -0
  232. sqlalchemy/testing/fixtures/orm.py +227 -0
  233. sqlalchemy/testing/fixtures/sql.py +503 -0
  234. sqlalchemy/testing/pickleable.py +155 -0
  235. sqlalchemy/testing/plugin/__init__.py +6 -0
  236. sqlalchemy/testing/plugin/bootstrap.py +51 -0
  237. sqlalchemy/testing/plugin/plugin_base.py +779 -0
  238. sqlalchemy/testing/plugin/pytestplugin.py +868 -0
  239. sqlalchemy/testing/profiling.py +324 -0
  240. sqlalchemy/testing/provision.py +496 -0
  241. sqlalchemy/testing/requirements.py +1818 -0
  242. sqlalchemy/testing/schema.py +224 -0
  243. sqlalchemy/testing/suite/__init__.py +19 -0
  244. sqlalchemy/testing/suite/test_cte.py +211 -0
  245. sqlalchemy/testing/suite/test_ddl.py +389 -0
  246. sqlalchemy/testing/suite/test_deprecations.py +153 -0
  247. sqlalchemy/testing/suite/test_dialect.py +740 -0
  248. sqlalchemy/testing/suite/test_insert.py +630 -0
  249. sqlalchemy/testing/suite/test_reflection.py +3225 -0
  250. sqlalchemy/testing/suite/test_results.py +502 -0
  251. sqlalchemy/testing/suite/test_rowcount.py +258 -0
  252. sqlalchemy/testing/suite/test_select.py +1999 -0
  253. sqlalchemy/testing/suite/test_sequence.py +317 -0
  254. sqlalchemy/testing/suite/test_types.py +2141 -0
  255. sqlalchemy/testing/suite/test_unicode_ddl.py +189 -0
  256. sqlalchemy/testing/suite/test_update_delete.py +139 -0
  257. sqlalchemy/testing/util.py +537 -0
  258. sqlalchemy/testing/warnings.py +52 -0
  259. sqlalchemy/types.py +76 -0
  260. sqlalchemy/util/__init__.py +160 -0
  261. sqlalchemy/util/_collections.py +715 -0
  262. sqlalchemy/util/_concurrency_py3k.py +288 -0
  263. sqlalchemy/util/_has_cy.py +40 -0
  264. sqlalchemy/util/_py_collections.py +541 -0
  265. sqlalchemy/util/compat.py +301 -0
  266. sqlalchemy/util/concurrency.py +108 -0
  267. sqlalchemy/util/deprecations.py +401 -0
  268. sqlalchemy/util/langhelpers.py +2218 -0
  269. sqlalchemy/util/preloaded.py +150 -0
  270. sqlalchemy/util/queue.py +322 -0
  271. sqlalchemy/util/tool_support.py +201 -0
  272. sqlalchemy/util/topological.py +120 -0
  273. sqlalchemy/util/typing.py +629 -0
@@ -0,0 +1,3403 @@
1
+ # engine/interfaces.py
2
+ # Copyright (C) 2005-2024 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 core interfaces used by the engine system."""
9
+
10
+ from __future__ import annotations
11
+
12
+ from enum import Enum
13
+ from types import ModuleType
14
+ from typing import Any
15
+ from typing import Awaitable
16
+ from typing import Callable
17
+ from typing import ClassVar
18
+ from typing import Collection
19
+ from typing import Dict
20
+ from typing import Iterable
21
+ from typing import Iterator
22
+ from typing import List
23
+ from typing import Mapping
24
+ from typing import MutableMapping
25
+ from typing import Optional
26
+ from typing import Sequence
27
+ from typing import Set
28
+ from typing import Tuple
29
+ from typing import Type
30
+ from typing import TYPE_CHECKING
31
+ from typing import TypeVar
32
+ from typing import Union
33
+
34
+ from .. import util
35
+ from ..event import EventTarget
36
+ from ..pool import Pool
37
+ from ..pool import PoolProxiedConnection
38
+ from ..sql.compiler import Compiled as Compiled
39
+ from ..sql.compiler import Compiled # noqa
40
+ from ..sql.compiler import TypeCompiler as TypeCompiler
41
+ from ..sql.compiler import TypeCompiler # noqa
42
+ from ..util import immutabledict
43
+ from ..util.concurrency import await_only
44
+ from ..util.typing import Literal
45
+ from ..util.typing import NotRequired
46
+ from ..util.typing import Protocol
47
+ from ..util.typing import TypedDict
48
+
49
+ if TYPE_CHECKING:
50
+ from .base import Connection
51
+ from .base import Engine
52
+ from .cursor import CursorResult
53
+ from .url import URL
54
+ from ..event import _ListenerFnType
55
+ from ..event import dispatcher
56
+ from ..exc import StatementError
57
+ from ..sql import Executable
58
+ from ..sql.compiler import _InsertManyValuesBatch
59
+ from ..sql.compiler import DDLCompiler
60
+ from ..sql.compiler import IdentifierPreparer
61
+ from ..sql.compiler import InsertmanyvaluesSentinelOpts
62
+ from ..sql.compiler import Linting
63
+ from ..sql.compiler import SQLCompiler
64
+ from ..sql.elements import BindParameter
65
+ from ..sql.elements import ClauseElement
66
+ from ..sql.schema import Column
67
+ from ..sql.schema import DefaultGenerator
68
+ from ..sql.schema import SchemaItem
69
+ from ..sql.schema import Sequence as Sequence_SchemaItem
70
+ from ..sql.sqltypes import Integer
71
+ from ..sql.type_api import _TypeMemoDict
72
+ from ..sql.type_api import TypeEngine
73
+
74
+ ConnectArgsType = Tuple[Sequence[str], MutableMapping[str, Any]]
75
+
76
+ _T = TypeVar("_T", bound="Any")
77
+
78
+
79
+ class CacheStats(Enum):
80
+ CACHE_HIT = 0
81
+ CACHE_MISS = 1
82
+ CACHING_DISABLED = 2
83
+ NO_CACHE_KEY = 3
84
+ NO_DIALECT_SUPPORT = 4
85
+
86
+
87
+ class ExecuteStyle(Enum):
88
+ """indicates the :term:`DBAPI` cursor method that will be used to invoke
89
+ a statement."""
90
+
91
+ EXECUTE = 0
92
+ """indicates cursor.execute() will be used"""
93
+
94
+ EXECUTEMANY = 1
95
+ """indicates cursor.executemany() will be used."""
96
+
97
+ INSERTMANYVALUES = 2
98
+ """indicates cursor.execute() will be used with an INSERT where the
99
+ VALUES expression will be expanded to accommodate for multiple
100
+ parameter sets
101
+
102
+ .. seealso::
103
+
104
+ :ref:`engine_insertmanyvalues`
105
+
106
+ """
107
+
108
+
109
+ class DBAPIConnection(Protocol):
110
+ """protocol representing a :pep:`249` database connection.
111
+
112
+ .. versionadded:: 2.0
113
+
114
+ .. seealso::
115
+
116
+ `Connection Objects <https://www.python.org/dev/peps/pep-0249/#connection-objects>`_
117
+ - in :pep:`249`
118
+
119
+ """ # noqa: E501
120
+
121
+ def close(self) -> None: ...
122
+
123
+ def commit(self) -> None: ...
124
+
125
+ def cursor(self) -> DBAPICursor: ...
126
+
127
+ def rollback(self) -> None: ...
128
+
129
+ autocommit: bool
130
+
131
+
132
+ class DBAPIType(Protocol):
133
+ """protocol representing a :pep:`249` database type.
134
+
135
+ .. versionadded:: 2.0
136
+
137
+ .. seealso::
138
+
139
+ `Type Objects <https://www.python.org/dev/peps/pep-0249/#type-objects>`_
140
+ - in :pep:`249`
141
+
142
+ """ # noqa: E501
143
+
144
+
145
+ class DBAPICursor(Protocol):
146
+ """protocol representing a :pep:`249` database cursor.
147
+
148
+ .. versionadded:: 2.0
149
+
150
+ .. seealso::
151
+
152
+ `Cursor Objects <https://www.python.org/dev/peps/pep-0249/#cursor-objects>`_
153
+ - in :pep:`249`
154
+
155
+ """ # noqa: E501
156
+
157
+ @property
158
+ def description(
159
+ self,
160
+ ) -> _DBAPICursorDescription:
161
+ """The description attribute of the Cursor.
162
+
163
+ .. seealso::
164
+
165
+ `cursor.description <https://www.python.org/dev/peps/pep-0249/#description>`_
166
+ - in :pep:`249`
167
+
168
+
169
+ """ # noqa: E501
170
+ ...
171
+
172
+ @property
173
+ def rowcount(self) -> int: ...
174
+
175
+ arraysize: int
176
+
177
+ lastrowid: int
178
+
179
+ def close(self) -> None: ...
180
+
181
+ def execute(
182
+ self,
183
+ operation: Any,
184
+ parameters: Optional[_DBAPISingleExecuteParams] = None,
185
+ ) -> Any: ...
186
+
187
+ def executemany(
188
+ self,
189
+ operation: Any,
190
+ parameters: _DBAPIMultiExecuteParams,
191
+ ) -> Any: ...
192
+
193
+ def fetchone(self) -> Optional[Any]: ...
194
+
195
+ def fetchmany(self, size: int = ...) -> Sequence[Any]: ...
196
+
197
+ def fetchall(self) -> Sequence[Any]: ...
198
+
199
+ def setinputsizes(self, sizes: Sequence[Any]) -> None: ...
200
+
201
+ def setoutputsize(self, size: Any, column: Any) -> None: ...
202
+
203
+ def callproc(
204
+ self, procname: str, parameters: Sequence[Any] = ...
205
+ ) -> Any: ...
206
+
207
+ def nextset(self) -> Optional[bool]: ...
208
+
209
+ def __getattr__(self, key: str) -> Any: ...
210
+
211
+
212
+ _CoreSingleExecuteParams = Mapping[str, Any]
213
+ _MutableCoreSingleExecuteParams = MutableMapping[str, Any]
214
+ _CoreMultiExecuteParams = Sequence[_CoreSingleExecuteParams]
215
+ _CoreAnyExecuteParams = Union[
216
+ _CoreMultiExecuteParams, _CoreSingleExecuteParams
217
+ ]
218
+
219
+ _DBAPISingleExecuteParams = Union[Sequence[Any], _CoreSingleExecuteParams]
220
+
221
+ _DBAPIMultiExecuteParams = Union[
222
+ Sequence[Sequence[Any]], _CoreMultiExecuteParams
223
+ ]
224
+ _DBAPIAnyExecuteParams = Union[
225
+ _DBAPIMultiExecuteParams, _DBAPISingleExecuteParams
226
+ ]
227
+ _DBAPICursorDescription = Sequence[
228
+ Tuple[
229
+ str,
230
+ "DBAPIType",
231
+ Optional[int],
232
+ Optional[int],
233
+ Optional[int],
234
+ Optional[int],
235
+ Optional[bool],
236
+ ]
237
+ ]
238
+
239
+ _AnySingleExecuteParams = _DBAPISingleExecuteParams
240
+ _AnyMultiExecuteParams = _DBAPIMultiExecuteParams
241
+ _AnyExecuteParams = _DBAPIAnyExecuteParams
242
+
243
+ CompiledCacheType = MutableMapping[Any, "Compiled"]
244
+ SchemaTranslateMapType = Mapping[Optional[str], Optional[str]]
245
+
246
+ _ImmutableExecuteOptions = immutabledict[str, Any]
247
+
248
+ _ParamStyle = Literal[
249
+ "qmark", "numeric", "named", "format", "pyformat", "numeric_dollar"
250
+ ]
251
+
252
+ _GenericSetInputSizesType = List[Tuple[str, Any, "TypeEngine[Any]"]]
253
+
254
+ IsolationLevel = Literal[
255
+ "SERIALIZABLE",
256
+ "REPEATABLE READ",
257
+ "READ COMMITTED",
258
+ "READ UNCOMMITTED",
259
+ "AUTOCOMMIT",
260
+ ]
261
+
262
+
263
+ class _CoreKnownExecutionOptions(TypedDict, total=False):
264
+ compiled_cache: Optional[CompiledCacheType]
265
+ logging_token: str
266
+ isolation_level: IsolationLevel
267
+ no_parameters: bool
268
+ stream_results: bool
269
+ max_row_buffer: int
270
+ yield_per: int
271
+ insertmanyvalues_page_size: int
272
+ schema_translate_map: Optional[SchemaTranslateMapType]
273
+ preserve_rowcount: bool
274
+
275
+
276
+ _ExecuteOptions = immutabledict[str, Any]
277
+ CoreExecuteOptionsParameter = Union[
278
+ _CoreKnownExecutionOptions, Mapping[str, Any]
279
+ ]
280
+
281
+
282
+ class ReflectedIdentity(TypedDict):
283
+ """represent the reflected IDENTITY structure of a column, corresponding
284
+ to the :class:`_schema.Identity` construct.
285
+
286
+ The :class:`.ReflectedIdentity` structure is part of the
287
+ :class:`.ReflectedColumn` structure, which is returned by the
288
+ :meth:`.Inspector.get_columns` method.
289
+
290
+ """
291
+
292
+ always: bool
293
+ """type of identity column"""
294
+
295
+ on_null: bool
296
+ """indicates ON NULL"""
297
+
298
+ start: int
299
+ """starting index of the sequence"""
300
+
301
+ increment: int
302
+ """increment value of the sequence"""
303
+
304
+ minvalue: int
305
+ """the minimum value of the sequence."""
306
+
307
+ maxvalue: int
308
+ """the maximum value of the sequence."""
309
+
310
+ nominvalue: bool
311
+ """no minimum value of the sequence."""
312
+
313
+ nomaxvalue: bool
314
+ """no maximum value of the sequence."""
315
+
316
+ cycle: bool
317
+ """allows the sequence to wrap around when the maxvalue
318
+ or minvalue has been reached."""
319
+
320
+ cache: Optional[int]
321
+ """number of future values in the
322
+ sequence which are calculated in advance."""
323
+
324
+ order: bool
325
+ """if true, renders the ORDER keyword."""
326
+
327
+
328
+ class ReflectedComputed(TypedDict):
329
+ """Represent the reflected elements of a computed column, corresponding
330
+ to the :class:`_schema.Computed` construct.
331
+
332
+ The :class:`.ReflectedComputed` structure is part of the
333
+ :class:`.ReflectedColumn` structure, which is returned by the
334
+ :meth:`.Inspector.get_columns` method.
335
+
336
+ """
337
+
338
+ sqltext: str
339
+ """the expression used to generate this column returned
340
+ as a string SQL expression"""
341
+
342
+ persisted: NotRequired[bool]
343
+ """indicates if the value is stored in the table or computed on demand"""
344
+
345
+
346
+ class ReflectedColumn(TypedDict):
347
+ """Dictionary representing the reflected elements corresponding to
348
+ a :class:`_schema.Column` object.
349
+
350
+ The :class:`.ReflectedColumn` structure is returned by the
351
+ :class:`.Inspector.get_columns` method.
352
+
353
+ """
354
+
355
+ name: str
356
+ """column name"""
357
+
358
+ type: TypeEngine[Any]
359
+ """column type represented as a :class:`.TypeEngine` instance."""
360
+
361
+ nullable: bool
362
+ """boolean flag if the column is NULL or NOT NULL"""
363
+
364
+ default: Optional[str]
365
+ """column default expression as a SQL string"""
366
+
367
+ autoincrement: NotRequired[bool]
368
+ """database-dependent autoincrement flag.
369
+
370
+ This flag indicates if the column has a database-side "autoincrement"
371
+ flag of some kind. Within SQLAlchemy, other kinds of columns may
372
+ also act as an "autoincrement" column without necessarily having
373
+ such a flag on them.
374
+
375
+ See :paramref:`_schema.Column.autoincrement` for more background on
376
+ "autoincrement".
377
+
378
+ """
379
+
380
+ comment: NotRequired[Optional[str]]
381
+ """comment for the column, if present.
382
+ Only some dialects return this key
383
+ """
384
+
385
+ computed: NotRequired[ReflectedComputed]
386
+ """indicates that this column is computed by the database.
387
+ Only some dialects return this key.
388
+
389
+ .. versionadded:: 1.3.16 - added support for computed reflection.
390
+ """
391
+
392
+ identity: NotRequired[ReflectedIdentity]
393
+ """indicates this column is an IDENTITY column.
394
+ Only some dialects return this key.
395
+
396
+ .. versionadded:: 1.4 - added support for identity column reflection.
397
+ """
398
+
399
+ dialect_options: NotRequired[Dict[str, Any]]
400
+ """Additional dialect-specific options detected for this reflected
401
+ object"""
402
+
403
+
404
+ class ReflectedConstraint(TypedDict):
405
+ """Dictionary representing the reflected elements corresponding to
406
+ :class:`.Constraint`
407
+
408
+ A base class for all constraints
409
+ """
410
+
411
+ name: Optional[str]
412
+ """constraint name"""
413
+
414
+ comment: NotRequired[Optional[str]]
415
+ """comment for the constraint, if present"""
416
+
417
+
418
+ class ReflectedCheckConstraint(ReflectedConstraint):
419
+ """Dictionary representing the reflected elements corresponding to
420
+ :class:`.CheckConstraint`.
421
+
422
+ The :class:`.ReflectedCheckConstraint` structure is returned by the
423
+ :meth:`.Inspector.get_check_constraints` method.
424
+
425
+ """
426
+
427
+ sqltext: str
428
+ """the check constraint's SQL expression"""
429
+
430
+ dialect_options: NotRequired[Dict[str, Any]]
431
+ """Additional dialect-specific options detected for this check constraint
432
+
433
+ .. versionadded:: 1.3.8
434
+ """
435
+
436
+
437
+ class ReflectedUniqueConstraint(ReflectedConstraint):
438
+ """Dictionary representing the reflected elements corresponding to
439
+ :class:`.UniqueConstraint`.
440
+
441
+ The :class:`.ReflectedUniqueConstraint` structure is returned by the
442
+ :meth:`.Inspector.get_unique_constraints` method.
443
+
444
+ """
445
+
446
+ column_names: List[str]
447
+ """column names which comprise the unique constraint"""
448
+
449
+ duplicates_index: NotRequired[Optional[str]]
450
+ "Indicates if this unique constraint duplicates an index with this name"
451
+
452
+ dialect_options: NotRequired[Dict[str, Any]]
453
+ """Additional dialect-specific options detected for this unique
454
+ constraint"""
455
+
456
+
457
+ class ReflectedPrimaryKeyConstraint(ReflectedConstraint):
458
+ """Dictionary representing the reflected elements corresponding to
459
+ :class:`.PrimaryKeyConstraint`.
460
+
461
+ The :class:`.ReflectedPrimaryKeyConstraint` structure is returned by the
462
+ :meth:`.Inspector.get_pk_constraint` method.
463
+
464
+ """
465
+
466
+ constrained_columns: List[str]
467
+ """column names which comprise the primary key"""
468
+
469
+ dialect_options: NotRequired[Dict[str, Any]]
470
+ """Additional dialect-specific options detected for this primary key"""
471
+
472
+
473
+ class ReflectedForeignKeyConstraint(ReflectedConstraint):
474
+ """Dictionary representing the reflected elements corresponding to
475
+ :class:`.ForeignKeyConstraint`.
476
+
477
+ The :class:`.ReflectedForeignKeyConstraint` structure is returned by
478
+ the :meth:`.Inspector.get_foreign_keys` method.
479
+
480
+ """
481
+
482
+ constrained_columns: List[str]
483
+ """local column names which comprise the foreign key"""
484
+
485
+ referred_schema: Optional[str]
486
+ """schema name of the table being referred"""
487
+
488
+ referred_table: str
489
+ """name of the table being referred"""
490
+
491
+ referred_columns: List[str]
492
+ """referred column names that correspond to ``constrained_columns``"""
493
+
494
+ options: NotRequired[Dict[str, Any]]
495
+ """Additional options detected for this foreign key constraint"""
496
+
497
+
498
+ class ReflectedIndex(TypedDict):
499
+ """Dictionary representing the reflected elements corresponding to
500
+ :class:`.Index`.
501
+
502
+ The :class:`.ReflectedIndex` structure is returned by the
503
+ :meth:`.Inspector.get_indexes` method.
504
+
505
+ """
506
+
507
+ name: Optional[str]
508
+ """index name"""
509
+
510
+ column_names: List[Optional[str]]
511
+ """column names which the index references.
512
+ An element of this list is ``None`` if it's an expression and is
513
+ returned in the ``expressions`` list.
514
+ """
515
+
516
+ expressions: NotRequired[List[str]]
517
+ """Expressions that compose the index. This list, when present, contains
518
+ both plain column names (that are also in ``column_names``) and
519
+ expressions (that are ``None`` in ``column_names``).
520
+ """
521
+
522
+ unique: bool
523
+ """whether or not the index has a unique flag"""
524
+
525
+ duplicates_constraint: NotRequired[Optional[str]]
526
+ "Indicates if this index mirrors a constraint with this name"
527
+
528
+ include_columns: NotRequired[List[str]]
529
+ """columns to include in the INCLUDE clause for supporting databases.
530
+
531
+ .. deprecated:: 2.0
532
+
533
+ Legacy value, will be replaced with
534
+ ``index_dict["dialect_options"]["<dialect name>_include"]``
535
+
536
+ """
537
+
538
+ column_sorting: NotRequired[Dict[str, Tuple[str]]]
539
+ """optional dict mapping column names or expressions to tuple of sort
540
+ keywords, which may include ``asc``, ``desc``, ``nulls_first``,
541
+ ``nulls_last``.
542
+
543
+ .. versionadded:: 1.3.5
544
+ """
545
+
546
+ dialect_options: NotRequired[Dict[str, Any]]
547
+ """Additional dialect-specific options detected for this index"""
548
+
549
+
550
+ class ReflectedTableComment(TypedDict):
551
+ """Dictionary representing the reflected comment corresponding to
552
+ the :attr:`_schema.Table.comment` attribute.
553
+
554
+ The :class:`.ReflectedTableComment` structure is returned by the
555
+ :meth:`.Inspector.get_table_comment` method.
556
+
557
+ """
558
+
559
+ text: Optional[str]
560
+ """text of the comment"""
561
+
562
+
563
+ class BindTyping(Enum):
564
+ """Define different methods of passing typing information for
565
+ bound parameters in a statement to the database driver.
566
+
567
+ .. versionadded:: 2.0
568
+
569
+ """
570
+
571
+ NONE = 1
572
+ """No steps are taken to pass typing information to the database driver.
573
+
574
+ This is the default behavior for databases such as SQLite, MySQL / MariaDB,
575
+ SQL Server.
576
+
577
+ """
578
+
579
+ SETINPUTSIZES = 2
580
+ """Use the pep-249 setinputsizes method.
581
+
582
+ This is only implemented for DBAPIs that support this method and for which
583
+ the SQLAlchemy dialect has the appropriate infrastructure for that
584
+ dialect set up. Current dialects include cx_Oracle as well as
585
+ optional support for SQL Server using pyodbc.
586
+
587
+ When using setinputsizes, dialects also have a means of only using the
588
+ method for certain datatypes using include/exclude lists.
589
+
590
+ When SETINPUTSIZES is used, the :meth:`.Dialect.do_set_input_sizes` method
591
+ is called for each statement executed which has bound parameters.
592
+
593
+ """
594
+
595
+ RENDER_CASTS = 3
596
+ """Render casts or other directives in the SQL string.
597
+
598
+ This method is used for all PostgreSQL dialects, including asyncpg,
599
+ pg8000, psycopg, psycopg2. Dialects which implement this can choose
600
+ which kinds of datatypes are explicitly cast in SQL statements and which
601
+ aren't.
602
+
603
+ When RENDER_CASTS is used, the compiler will invoke the
604
+ :meth:`.SQLCompiler.render_bind_cast` method for the rendered
605
+ string representation of each :class:`.BindParameter` object whose
606
+ dialect-level type sets the :attr:`.TypeEngine.render_bind_cast` attribute.
607
+
608
+ The :meth:`.SQLCompiler.render_bind_cast` is also used to render casts
609
+ for one form of "insertmanyvalues" query, when both
610
+ :attr:`.InsertmanyvaluesSentinelOpts.USE_INSERT_FROM_SELECT` and
611
+ :attr:`.InsertmanyvaluesSentinelOpts.RENDER_SELECT_COL_CASTS` are set,
612
+ where the casts are applied to the intermediary columns e.g.
613
+ "INSERT INTO t (a, b, c) SELECT p0::TYP, p1::TYP, p2::TYP "
614
+ "FROM (VALUES (?, ?), (?, ?), ...)".
615
+
616
+ .. versionadded:: 2.0.10 - :meth:`.SQLCompiler.render_bind_cast` is now
617
+ used within some elements of the "insertmanyvalues" implementation.
618
+
619
+
620
+ """
621
+
622
+
623
+ VersionInfoType = Tuple[Union[int, str], ...]
624
+ TableKey = Tuple[Optional[str], str]
625
+
626
+
627
+ class Dialect(EventTarget):
628
+ """Define the behavior of a specific database and DB-API combination.
629
+
630
+ Any aspect of metadata definition, SQL query generation,
631
+ execution, result-set handling, or anything else which varies
632
+ between databases is defined under the general category of the
633
+ Dialect. The Dialect acts as a factory for other
634
+ database-specific object implementations including
635
+ ExecutionContext, Compiled, DefaultGenerator, and TypeEngine.
636
+
637
+ .. note:: Third party dialects should not subclass :class:`.Dialect`
638
+ directly. Instead, subclass :class:`.default.DefaultDialect` or
639
+ descendant class.
640
+
641
+ """
642
+
643
+ CACHE_HIT = CacheStats.CACHE_HIT
644
+ CACHE_MISS = CacheStats.CACHE_MISS
645
+ CACHING_DISABLED = CacheStats.CACHING_DISABLED
646
+ NO_CACHE_KEY = CacheStats.NO_CACHE_KEY
647
+ NO_DIALECT_SUPPORT = CacheStats.NO_DIALECT_SUPPORT
648
+
649
+ dispatch: dispatcher[Dialect]
650
+
651
+ name: str
652
+ """identifying name for the dialect from a DBAPI-neutral point of view
653
+ (i.e. 'sqlite')
654
+ """
655
+
656
+ driver: str
657
+ """identifying name for the dialect's DBAPI"""
658
+
659
+ dialect_description: str
660
+
661
+ dbapi: Optional[ModuleType]
662
+ """A reference to the DBAPI module object itself.
663
+
664
+ SQLAlchemy dialects import DBAPI modules using the classmethod
665
+ :meth:`.Dialect.import_dbapi`. The rationale is so that any dialect
666
+ module can be imported and used to generate SQL statements without the
667
+ need for the actual DBAPI driver to be installed. Only when an
668
+ :class:`.Engine` is constructed using :func:`.create_engine` does the
669
+ DBAPI get imported; at that point, the creation process will assign
670
+ the DBAPI module to this attribute.
671
+
672
+ Dialects should therefore implement :meth:`.Dialect.import_dbapi`
673
+ which will import the necessary module and return it, and then refer
674
+ to ``self.dbapi`` in dialect code in order to refer to the DBAPI module
675
+ contents.
676
+
677
+ .. versionchanged:: The :attr:`.Dialect.dbapi` attribute is exclusively
678
+ used as the per-:class:`.Dialect`-instance reference to the DBAPI
679
+ module. The previous not-fully-documented ``.Dialect.dbapi()``
680
+ classmethod is deprecated and replaced by :meth:`.Dialect.import_dbapi`.
681
+
682
+ """
683
+
684
+ @util.non_memoized_property
685
+ def loaded_dbapi(self) -> ModuleType:
686
+ """same as .dbapi, but is never None; will raise an error if no
687
+ DBAPI was set up.
688
+
689
+ .. versionadded:: 2.0
690
+
691
+ """
692
+ raise NotImplementedError()
693
+
694
+ positional: bool
695
+ """True if the paramstyle for this Dialect is positional."""
696
+
697
+ paramstyle: str
698
+ """the paramstyle to be used (some DB-APIs support multiple
699
+ paramstyles).
700
+ """
701
+
702
+ compiler_linting: Linting
703
+
704
+ statement_compiler: Type[SQLCompiler]
705
+ """a :class:`.Compiled` class used to compile SQL statements"""
706
+
707
+ ddl_compiler: Type[DDLCompiler]
708
+ """a :class:`.Compiled` class used to compile DDL statements"""
709
+
710
+ type_compiler_cls: ClassVar[Type[TypeCompiler]]
711
+ """a :class:`.Compiled` class used to compile SQL type objects
712
+
713
+ .. versionadded:: 2.0
714
+
715
+ """
716
+
717
+ type_compiler_instance: TypeCompiler
718
+ """instance of a :class:`.Compiled` class used to compile SQL type
719
+ objects
720
+
721
+ .. versionadded:: 2.0
722
+
723
+ """
724
+
725
+ type_compiler: Any
726
+ """legacy; this is a TypeCompiler class at the class level, a
727
+ TypeCompiler instance at the instance level.
728
+
729
+ Refer to type_compiler_instance instead.
730
+
731
+ """
732
+
733
+ preparer: Type[IdentifierPreparer]
734
+ """a :class:`.IdentifierPreparer` class used to
735
+ quote identifiers.
736
+ """
737
+
738
+ identifier_preparer: IdentifierPreparer
739
+ """This element will refer to an instance of :class:`.IdentifierPreparer`
740
+ once a :class:`.DefaultDialect` has been constructed.
741
+
742
+ """
743
+
744
+ server_version_info: Optional[Tuple[Any, ...]]
745
+ """a tuple containing a version number for the DB backend in use.
746
+
747
+ This value is only available for supporting dialects, and is
748
+ typically populated during the initial connection to the database.
749
+ """
750
+
751
+ default_schema_name: Optional[str]
752
+ """the name of the default schema. This value is only available for
753
+ supporting dialects, and is typically populated during the
754
+ initial connection to the database.
755
+
756
+ """
757
+
758
+ # NOTE: this does not take into effect engine-level isolation level.
759
+ # not clear if this should be changed, seems like it should
760
+ default_isolation_level: Optional[IsolationLevel]
761
+ """the isolation that is implicitly present on new connections"""
762
+
763
+ # create_engine() -> isolation_level currently goes here
764
+ _on_connect_isolation_level: Optional[IsolationLevel]
765
+
766
+ execution_ctx_cls: Type[ExecutionContext]
767
+ """a :class:`.ExecutionContext` class used to handle statement execution"""
768
+
769
+ execute_sequence_format: Union[
770
+ Type[Tuple[Any, ...]], Type[Tuple[List[Any]]]
771
+ ]
772
+ """either the 'tuple' or 'list' type, depending on what cursor.execute()
773
+ accepts for the second argument (they vary)."""
774
+
775
+ supports_alter: bool
776
+ """``True`` if the database supports ``ALTER TABLE`` - used only for
777
+ generating foreign key constraints in certain circumstances
778
+ """
779
+
780
+ max_identifier_length: int
781
+ """The maximum length of identifier names."""
782
+
783
+ supports_server_side_cursors: bool
784
+ """indicates if the dialect supports server side cursors"""
785
+
786
+ server_side_cursors: bool
787
+ """deprecated; indicates if the dialect should attempt to use server
788
+ side cursors by default"""
789
+
790
+ supports_sane_rowcount: bool
791
+ """Indicate whether the dialect properly implements rowcount for
792
+ ``UPDATE`` and ``DELETE`` statements.
793
+ """
794
+
795
+ supports_sane_multi_rowcount: bool
796
+ """Indicate whether the dialect properly implements rowcount for
797
+ ``UPDATE`` and ``DELETE`` statements when executed via
798
+ executemany.
799
+ """
800
+
801
+ supports_empty_insert: bool
802
+ """dialect supports INSERT () VALUES (), i.e. a plain INSERT with no
803
+ columns in it.
804
+
805
+ This is not usually supported; an "empty" insert is typically
806
+ suited using either "INSERT..DEFAULT VALUES" or
807
+ "INSERT ... (col) VALUES (DEFAULT)".
808
+
809
+ """
810
+
811
+ supports_default_values: bool
812
+ """dialect supports INSERT... DEFAULT VALUES syntax"""
813
+
814
+ supports_default_metavalue: bool
815
+ """dialect supports INSERT...(col) VALUES (DEFAULT) syntax.
816
+
817
+ Most databases support this in some way, e.g. SQLite supports it using
818
+ ``VALUES (NULL)``. MS SQL Server supports the syntax also however
819
+ is the only included dialect where we have this disabled, as
820
+ MSSQL does not support the field for the IDENTITY column, which is
821
+ usually where we like to make use of the feature.
822
+
823
+ """
824
+
825
+ default_metavalue_token: str = "DEFAULT"
826
+ """for INSERT... VALUES (DEFAULT) syntax, the token to put in the
827
+ parenthesis.
828
+
829
+ E.g. for SQLite this is the keyword "NULL".
830
+
831
+ """
832
+
833
+ supports_multivalues_insert: bool
834
+ """Target database supports INSERT...VALUES with multiple value
835
+ sets, i.e. INSERT INTO table (cols) VALUES (...), (...), (...), ...
836
+
837
+ """
838
+
839
+ insert_executemany_returning: bool
840
+ """dialect / driver / database supports some means of providing
841
+ INSERT...RETURNING support when dialect.do_executemany() is used.
842
+
843
+ """
844
+
845
+ insert_executemany_returning_sort_by_parameter_order: bool
846
+ """dialect / driver / database supports some means of providing
847
+ INSERT...RETURNING support when dialect.do_executemany() is used
848
+ along with the :paramref:`_dml.Insert.returning.sort_by_parameter_order`
849
+ parameter being set.
850
+
851
+ """
852
+
853
+ update_executemany_returning: bool
854
+ """dialect supports UPDATE..RETURNING with executemany."""
855
+
856
+ delete_executemany_returning: bool
857
+ """dialect supports DELETE..RETURNING with executemany."""
858
+
859
+ use_insertmanyvalues: bool
860
+ """if True, indicates "insertmanyvalues" functionality should be used
861
+ to allow for ``insert_executemany_returning`` behavior, if possible.
862
+
863
+ In practice, setting this to True means:
864
+
865
+ if ``supports_multivalues_insert``, ``insert_returning`` and
866
+ ``use_insertmanyvalues`` are all True, the SQL compiler will produce
867
+ an INSERT that will be interpreted by the :class:`.DefaultDialect`
868
+ as an :attr:`.ExecuteStyle.INSERTMANYVALUES` execution that allows
869
+ for INSERT of many rows with RETURNING by rewriting a single-row
870
+ INSERT statement to have multiple VALUES clauses, also executing
871
+ the statement multiple times for a series of batches when large numbers
872
+ of rows are given.
873
+
874
+ The parameter is False for the default dialect, and is set to
875
+ True for SQLAlchemy internal dialects SQLite, MySQL/MariaDB, PostgreSQL,
876
+ SQL Server. It remains at False for Oracle, which provides native
877
+ "executemany with RETURNING" support and also does not support
878
+ ``supports_multivalues_insert``. For MySQL/MariaDB, those MySQL
879
+ dialects that don't support RETURNING will not report
880
+ ``insert_executemany_returning`` as True.
881
+
882
+ .. versionadded:: 2.0
883
+
884
+ .. seealso::
885
+
886
+ :ref:`engine_insertmanyvalues`
887
+
888
+ """
889
+
890
+ use_insertmanyvalues_wo_returning: bool
891
+ """if True, and use_insertmanyvalues is also True, INSERT statements
892
+ that don't include RETURNING will also use "insertmanyvalues".
893
+
894
+ .. versionadded:: 2.0
895
+
896
+ .. seealso::
897
+
898
+ :ref:`engine_insertmanyvalues`
899
+
900
+ """
901
+
902
+ insertmanyvalues_implicit_sentinel: InsertmanyvaluesSentinelOpts
903
+ """Options indicating the database supports a form of bulk INSERT where
904
+ the autoincrement integer primary key can be reliably used as an ordering
905
+ for INSERTed rows.
906
+
907
+ .. versionadded:: 2.0.10
908
+
909
+ .. seealso::
910
+
911
+ :ref:`engine_insertmanyvalues_returning_order`
912
+
913
+ """
914
+
915
+ insertmanyvalues_page_size: int
916
+ """Number of rows to render into an individual INSERT..VALUES() statement
917
+ for :attr:`.ExecuteStyle.INSERTMANYVALUES` executions.
918
+
919
+ The default dialect defaults this to 1000.
920
+
921
+ .. versionadded:: 2.0
922
+
923
+ .. seealso::
924
+
925
+ :paramref:`_engine.Connection.execution_options.insertmanyvalues_page_size` -
926
+ execution option available on :class:`_engine.Connection`, statements
927
+
928
+ """ # noqa: E501
929
+
930
+ insertmanyvalues_max_parameters: int
931
+ """Alternate to insertmanyvalues_page_size, will additionally limit
932
+ page size based on number of parameters total in the statement.
933
+
934
+
935
+ """
936
+
937
+ preexecute_autoincrement_sequences: bool
938
+ """True if 'implicit' primary key functions must be executed separately
939
+ in order to get their value, if RETURNING is not used.
940
+
941
+ This is currently oriented towards PostgreSQL when the
942
+ ``implicit_returning=False`` parameter is used on a :class:`.Table`
943
+ object.
944
+
945
+ """
946
+
947
+ insert_returning: bool
948
+ """if the dialect supports RETURNING with INSERT
949
+
950
+ .. versionadded:: 2.0
951
+
952
+ """
953
+
954
+ update_returning: bool
955
+ """if the dialect supports RETURNING with UPDATE
956
+
957
+ .. versionadded:: 2.0
958
+
959
+ """
960
+
961
+ update_returning_multifrom: bool
962
+ """if the dialect supports RETURNING with UPDATE..FROM
963
+
964
+ .. versionadded:: 2.0
965
+
966
+ """
967
+
968
+ delete_returning: bool
969
+ """if the dialect supports RETURNING with DELETE
970
+
971
+ .. versionadded:: 2.0
972
+
973
+ """
974
+
975
+ delete_returning_multifrom: bool
976
+ """if the dialect supports RETURNING with DELETE..FROM
977
+
978
+ .. versionadded:: 2.0
979
+
980
+ """
981
+
982
+ favor_returning_over_lastrowid: bool
983
+ """for backends that support both a lastrowid and a RETURNING insert
984
+ strategy, favor RETURNING for simple single-int pk inserts.
985
+
986
+ cursor.lastrowid tends to be more performant on most backends.
987
+
988
+ """
989
+
990
+ supports_identity_columns: bool
991
+ """target database supports IDENTITY"""
992
+
993
+ cte_follows_insert: bool
994
+ """target database, when given a CTE with an INSERT statement, needs
995
+ the CTE to be below the INSERT"""
996
+
997
+ colspecs: MutableMapping[Type[TypeEngine[Any]], Type[TypeEngine[Any]]]
998
+ """A dictionary of TypeEngine classes from sqlalchemy.types mapped
999
+ to subclasses that are specific to the dialect class. This
1000
+ dictionary is class-level only and is not accessed from the
1001
+ dialect instance itself.
1002
+ """
1003
+
1004
+ supports_sequences: bool
1005
+ """Indicates if the dialect supports CREATE SEQUENCE or similar."""
1006
+
1007
+ sequences_optional: bool
1008
+ """If True, indicates if the :paramref:`_schema.Sequence.optional`
1009
+ parameter on the :class:`_schema.Sequence` construct
1010
+ should signal to not generate a CREATE SEQUENCE. Applies only to
1011
+ dialects that support sequences. Currently used only to allow PostgreSQL
1012
+ SERIAL to be used on a column that specifies Sequence() for usage on
1013
+ other backends.
1014
+ """
1015
+
1016
+ default_sequence_base: int
1017
+ """the default value that will be rendered as the "START WITH" portion of
1018
+ a CREATE SEQUENCE DDL statement.
1019
+
1020
+ """
1021
+
1022
+ supports_native_enum: bool
1023
+ """Indicates if the dialect supports a native ENUM construct.
1024
+ This will prevent :class:`_types.Enum` from generating a CHECK
1025
+ constraint when that type is used in "native" mode.
1026
+ """
1027
+
1028
+ supports_native_boolean: bool
1029
+ """Indicates if the dialect supports a native boolean construct.
1030
+ This will prevent :class:`_types.Boolean` from generating a CHECK
1031
+ constraint when that type is used.
1032
+ """
1033
+
1034
+ supports_native_decimal: bool
1035
+ """indicates if Decimal objects are handled and returned for precision
1036
+ numeric types, or if floats are returned"""
1037
+
1038
+ supports_native_uuid: bool
1039
+ """indicates if Python UUID() objects are handled natively by the
1040
+ driver for SQL UUID datatypes.
1041
+
1042
+ .. versionadded:: 2.0
1043
+
1044
+ """
1045
+
1046
+ returns_native_bytes: bool
1047
+ """indicates if Python bytes() objects are returned natively by the
1048
+ driver for SQL "binary" datatypes.
1049
+
1050
+ .. versionadded:: 2.0.11
1051
+
1052
+ """
1053
+
1054
+ construct_arguments: Optional[
1055
+ List[Tuple[Type[Union[SchemaItem, ClauseElement]], Mapping[str, Any]]]
1056
+ ] = None
1057
+ """Optional set of argument specifiers for various SQLAlchemy
1058
+ constructs, typically schema items.
1059
+
1060
+ To implement, establish as a series of tuples, as in::
1061
+
1062
+ construct_arguments = [
1063
+ (schema.Index, {
1064
+ "using": False,
1065
+ "where": None,
1066
+ "ops": None
1067
+ })
1068
+ ]
1069
+
1070
+ If the above construct is established on the PostgreSQL dialect,
1071
+ the :class:`.Index` construct will now accept the keyword arguments
1072
+ ``postgresql_using``, ``postgresql_where``, nad ``postgresql_ops``.
1073
+ Any other argument specified to the constructor of :class:`.Index`
1074
+ which is prefixed with ``postgresql_`` will raise :class:`.ArgumentError`.
1075
+
1076
+ A dialect which does not include a ``construct_arguments`` member will
1077
+ not participate in the argument validation system. For such a dialect,
1078
+ any argument name is accepted by all participating constructs, within
1079
+ the namespace of arguments prefixed with that dialect name. The rationale
1080
+ here is so that third-party dialects that haven't yet implemented this
1081
+ feature continue to function in the old way.
1082
+
1083
+ .. seealso::
1084
+
1085
+ :class:`.DialectKWArgs` - implementing base class which consumes
1086
+ :attr:`.DefaultDialect.construct_arguments`
1087
+
1088
+
1089
+ """
1090
+
1091
+ reflection_options: Sequence[str] = ()
1092
+ """Sequence of string names indicating keyword arguments that can be
1093
+ established on a :class:`.Table` object which will be passed as
1094
+ "reflection options" when using :paramref:`.Table.autoload_with`.
1095
+
1096
+ Current example is "oracle_resolve_synonyms" in the Oracle dialect.
1097
+
1098
+ """
1099
+
1100
+ dbapi_exception_translation_map: Mapping[str, str] = util.EMPTY_DICT
1101
+ """A dictionary of names that will contain as values the names of
1102
+ pep-249 exceptions ("IntegrityError", "OperationalError", etc)
1103
+ keyed to alternate class names, to support the case where a
1104
+ DBAPI has exception classes that aren't named as they are
1105
+ referred to (e.g. IntegrityError = MyException). In the vast
1106
+ majority of cases this dictionary is empty.
1107
+ """
1108
+
1109
+ supports_comments: bool
1110
+ """Indicates the dialect supports comment DDL on tables and columns."""
1111
+
1112
+ inline_comments: bool
1113
+ """Indicates the dialect supports comment DDL that's inline with the
1114
+ definition of a Table or Column. If False, this implies that ALTER must
1115
+ be used to set table and column comments."""
1116
+
1117
+ supports_constraint_comments: bool
1118
+ """Indicates if the dialect supports comment DDL on constraints.
1119
+
1120
+ .. versionadded: 2.0
1121
+ """
1122
+
1123
+ _has_events = False
1124
+
1125
+ supports_statement_cache: bool = True
1126
+ """indicates if this dialect supports caching.
1127
+
1128
+ All dialects that are compatible with statement caching should set this
1129
+ flag to True directly on each dialect class and subclass that supports
1130
+ it. SQLAlchemy tests that this flag is locally present on each dialect
1131
+ subclass before it will use statement caching. This is to provide
1132
+ safety for legacy or new dialects that are not yet fully tested to be
1133
+ compliant with SQL statement caching.
1134
+
1135
+ .. versionadded:: 1.4.5
1136
+
1137
+ .. seealso::
1138
+
1139
+ :ref:`engine_thirdparty_caching`
1140
+
1141
+ """
1142
+
1143
+ _supports_statement_cache: bool
1144
+ """internal evaluation for supports_statement_cache"""
1145
+
1146
+ bind_typing = BindTyping.NONE
1147
+ """define a means of passing typing information to the database and/or
1148
+ driver for bound parameters.
1149
+
1150
+ See :class:`.BindTyping` for values.
1151
+
1152
+ .. versionadded:: 2.0
1153
+
1154
+ """
1155
+
1156
+ is_async: bool
1157
+ """Whether or not this dialect is intended for asyncio use."""
1158
+
1159
+ has_terminate: bool
1160
+ """Whether or not this dialect has a separate "terminate" implementation
1161
+ that does not block or require awaiting."""
1162
+
1163
+ engine_config_types: Mapping[str, Any]
1164
+ """a mapping of string keys that can be in an engine config linked to
1165
+ type conversion functions.
1166
+
1167
+ """
1168
+
1169
+ label_length: Optional[int]
1170
+ """optional user-defined max length for SQL labels"""
1171
+
1172
+ include_set_input_sizes: Optional[Set[Any]]
1173
+ """set of DBAPI type objects that should be included in
1174
+ automatic cursor.setinputsizes() calls.
1175
+
1176
+ This is only used if bind_typing is BindTyping.SET_INPUT_SIZES
1177
+
1178
+ """
1179
+
1180
+ exclude_set_input_sizes: Optional[Set[Any]]
1181
+ """set of DBAPI type objects that should be excluded in
1182
+ automatic cursor.setinputsizes() calls.
1183
+
1184
+ This is only used if bind_typing is BindTyping.SET_INPUT_SIZES
1185
+
1186
+ """
1187
+
1188
+ supports_simple_order_by_label: bool
1189
+ """target database supports ORDER BY <labelname>, where <labelname>
1190
+ refers to a label in the columns clause of the SELECT"""
1191
+
1192
+ div_is_floordiv: bool
1193
+ """target database treats the / division operator as "floor division" """
1194
+
1195
+ tuple_in_values: bool
1196
+ """target database supports tuple IN, i.e. (x, y) IN ((q, p), (r, z))"""
1197
+
1198
+ _bind_typing_render_casts: bool
1199
+
1200
+ _type_memos: MutableMapping[TypeEngine[Any], _TypeMemoDict]
1201
+
1202
+ def _builtin_onconnect(self) -> Optional[_ListenerFnType]:
1203
+ raise NotImplementedError()
1204
+
1205
+ def create_connect_args(self, url: URL) -> ConnectArgsType:
1206
+ """Build DB-API compatible connection arguments.
1207
+
1208
+ Given a :class:`.URL` object, returns a tuple
1209
+ consisting of a ``(*args, **kwargs)`` suitable to send directly
1210
+ to the dbapi's connect function. The arguments are sent to the
1211
+ :meth:`.Dialect.connect` method which then runs the DBAPI-level
1212
+ ``connect()`` function.
1213
+
1214
+ The method typically makes use of the
1215
+ :meth:`.URL.translate_connect_args`
1216
+ method in order to generate a dictionary of options.
1217
+
1218
+ The default implementation is::
1219
+
1220
+ def create_connect_args(self, url):
1221
+ opts = url.translate_connect_args()
1222
+ opts.update(url.query)
1223
+ return ([], opts)
1224
+
1225
+ :param url: a :class:`.URL` object
1226
+
1227
+ :return: a tuple of ``(*args, **kwargs)`` which will be passed to the
1228
+ :meth:`.Dialect.connect` method.
1229
+
1230
+ .. seealso::
1231
+
1232
+ :meth:`.URL.translate_connect_args`
1233
+
1234
+ """
1235
+
1236
+ raise NotImplementedError()
1237
+
1238
+ @classmethod
1239
+ def import_dbapi(cls) -> ModuleType:
1240
+ """Import the DBAPI module that is used by this dialect.
1241
+
1242
+ The Python module object returned here will be assigned as an
1243
+ instance variable to a constructed dialect under the name
1244
+ ``.dbapi``.
1245
+
1246
+ .. versionchanged:: 2.0 The :meth:`.Dialect.import_dbapi` class
1247
+ method is renamed from the previous method ``.Dialect.dbapi()``,
1248
+ which would be replaced at dialect instantiation time by the
1249
+ DBAPI module itself, thus using the same name in two different ways.
1250
+ If a ``.Dialect.dbapi()`` classmethod is present on a third-party
1251
+ dialect, it will be used and a deprecation warning will be emitted.
1252
+
1253
+ """
1254
+ raise NotImplementedError()
1255
+
1256
+ def type_descriptor(self, typeobj: TypeEngine[_T]) -> TypeEngine[_T]:
1257
+ """Transform a generic type to a dialect-specific type.
1258
+
1259
+ Dialect classes will usually use the
1260
+ :func:`_types.adapt_type` function in the types module to
1261
+ accomplish this.
1262
+
1263
+ The returned result is cached *per dialect class* so can
1264
+ contain no dialect-instance state.
1265
+
1266
+ """
1267
+
1268
+ raise NotImplementedError()
1269
+
1270
+ def initialize(self, connection: Connection) -> None:
1271
+ """Called during strategized creation of the dialect with a
1272
+ connection.
1273
+
1274
+ Allows dialects to configure options based on server version info or
1275
+ other properties.
1276
+
1277
+ The connection passed here is a SQLAlchemy Connection object,
1278
+ with full capabilities.
1279
+
1280
+ The initialize() method of the base dialect should be called via
1281
+ super().
1282
+
1283
+ .. note:: as of SQLAlchemy 1.4, this method is called **before**
1284
+ any :meth:`_engine.Dialect.on_connect` hooks are called.
1285
+
1286
+ """
1287
+
1288
+ pass
1289
+
1290
+ if TYPE_CHECKING:
1291
+
1292
+ def _overrides_default(self, method_name: str) -> bool: ...
1293
+
1294
+ def get_columns(
1295
+ self,
1296
+ connection: Connection,
1297
+ table_name: str,
1298
+ schema: Optional[str] = None,
1299
+ **kw: Any,
1300
+ ) -> List[ReflectedColumn]:
1301
+ """Return information about columns in ``table_name``.
1302
+
1303
+ Given a :class:`_engine.Connection`, a string
1304
+ ``table_name``, and an optional string ``schema``, return column
1305
+ information as a list of dictionaries
1306
+ corresponding to the :class:`.ReflectedColumn` dictionary.
1307
+
1308
+ This is an internal dialect method. Applications should use
1309
+ :meth:`.Inspector.get_columns`.
1310
+
1311
+ """
1312
+
1313
+ raise NotImplementedError()
1314
+
1315
+ def get_multi_columns(
1316
+ self,
1317
+ connection: Connection,
1318
+ *,
1319
+ schema: Optional[str] = None,
1320
+ filter_names: Optional[Collection[str]] = None,
1321
+ **kw: Any,
1322
+ ) -> Iterable[Tuple[TableKey, List[ReflectedColumn]]]:
1323
+ """Return information about columns in all tables in the
1324
+ given ``schema``.
1325
+
1326
+ This is an internal dialect method. Applications should use
1327
+ :meth:`.Inspector.get_multi_columns`.
1328
+
1329
+ .. note:: The :class:`_engine.DefaultDialect` provides a default
1330
+ implementation that will call the single table method for
1331
+ each object returned by :meth:`Dialect.get_table_names`,
1332
+ :meth:`Dialect.get_view_names` or
1333
+ :meth:`Dialect.get_materialized_view_names` depending on the
1334
+ provided ``kind``. Dialects that want to support a faster
1335
+ implementation should implement this method.
1336
+
1337
+ .. versionadded:: 2.0
1338
+
1339
+ """
1340
+
1341
+ raise NotImplementedError()
1342
+
1343
+ def get_pk_constraint(
1344
+ self,
1345
+ connection: Connection,
1346
+ table_name: str,
1347
+ schema: Optional[str] = None,
1348
+ **kw: Any,
1349
+ ) -> ReflectedPrimaryKeyConstraint:
1350
+ """Return information about the primary key constraint on
1351
+ table_name`.
1352
+
1353
+ Given a :class:`_engine.Connection`, a string
1354
+ ``table_name``, and an optional string ``schema``, return primary
1355
+ key information as a dictionary corresponding to the
1356
+ :class:`.ReflectedPrimaryKeyConstraint` dictionary.
1357
+
1358
+ This is an internal dialect method. Applications should use
1359
+ :meth:`.Inspector.get_pk_constraint`.
1360
+
1361
+ """
1362
+ raise NotImplementedError()
1363
+
1364
+ def get_multi_pk_constraint(
1365
+ self,
1366
+ connection: Connection,
1367
+ *,
1368
+ schema: Optional[str] = None,
1369
+ filter_names: Optional[Collection[str]] = None,
1370
+ **kw: Any,
1371
+ ) -> Iterable[Tuple[TableKey, ReflectedPrimaryKeyConstraint]]:
1372
+ """Return information about primary key constraints in
1373
+ all tables in the given ``schema``.
1374
+
1375
+ This is an internal dialect method. Applications should use
1376
+ :meth:`.Inspector.get_multi_pk_constraint`.
1377
+
1378
+ .. note:: The :class:`_engine.DefaultDialect` provides a default
1379
+ implementation that will call the single table method for
1380
+ each object returned by :meth:`Dialect.get_table_names`,
1381
+ :meth:`Dialect.get_view_names` or
1382
+ :meth:`Dialect.get_materialized_view_names` depending on the
1383
+ provided ``kind``. Dialects that want to support a faster
1384
+ implementation should implement this method.
1385
+
1386
+ .. versionadded:: 2.0
1387
+
1388
+ """
1389
+ raise NotImplementedError()
1390
+
1391
+ def get_foreign_keys(
1392
+ self,
1393
+ connection: Connection,
1394
+ table_name: str,
1395
+ schema: Optional[str] = None,
1396
+ **kw: Any,
1397
+ ) -> List[ReflectedForeignKeyConstraint]:
1398
+ """Return information about foreign_keys in ``table_name``.
1399
+
1400
+ Given a :class:`_engine.Connection`, a string
1401
+ ``table_name``, and an optional string ``schema``, return foreign
1402
+ key information as a list of dicts corresponding to the
1403
+ :class:`.ReflectedForeignKeyConstraint` dictionary.
1404
+
1405
+ This is an internal dialect method. Applications should use
1406
+ :meth:`_engine.Inspector.get_foreign_keys`.
1407
+ """
1408
+
1409
+ raise NotImplementedError()
1410
+
1411
+ def get_multi_foreign_keys(
1412
+ self,
1413
+ connection: Connection,
1414
+ *,
1415
+ schema: Optional[str] = None,
1416
+ filter_names: Optional[Collection[str]] = None,
1417
+ **kw: Any,
1418
+ ) -> Iterable[Tuple[TableKey, List[ReflectedForeignKeyConstraint]]]:
1419
+ """Return information about foreign_keys in all tables
1420
+ in the given ``schema``.
1421
+
1422
+ This is an internal dialect method. Applications should use
1423
+ :meth:`_engine.Inspector.get_multi_foreign_keys`.
1424
+
1425
+ .. note:: The :class:`_engine.DefaultDialect` provides a default
1426
+ implementation that will call the single table method for
1427
+ each object returned by :meth:`Dialect.get_table_names`,
1428
+ :meth:`Dialect.get_view_names` or
1429
+ :meth:`Dialect.get_materialized_view_names` depending on the
1430
+ provided ``kind``. Dialects that want to support a faster
1431
+ implementation should implement this method.
1432
+
1433
+ .. versionadded:: 2.0
1434
+
1435
+ """
1436
+
1437
+ raise NotImplementedError()
1438
+
1439
+ def get_table_names(
1440
+ self, connection: Connection, schema: Optional[str] = None, **kw: Any
1441
+ ) -> List[str]:
1442
+ """Return a list of table names for ``schema``.
1443
+
1444
+ This is an internal dialect method. Applications should use
1445
+ :meth:`_engine.Inspector.get_table_names`.
1446
+
1447
+ """
1448
+
1449
+ raise NotImplementedError()
1450
+
1451
+ def get_temp_table_names(
1452
+ self, connection: Connection, schema: Optional[str] = None, **kw: Any
1453
+ ) -> List[str]:
1454
+ """Return a list of temporary table names on the given connection,
1455
+ if supported by the underlying backend.
1456
+
1457
+ This is an internal dialect method. Applications should use
1458
+ :meth:`_engine.Inspector.get_temp_table_names`.
1459
+
1460
+ """
1461
+
1462
+ raise NotImplementedError()
1463
+
1464
+ def get_view_names(
1465
+ self, connection: Connection, schema: Optional[str] = None, **kw: Any
1466
+ ) -> List[str]:
1467
+ """Return a list of all non-materialized view names available in the
1468
+ database.
1469
+
1470
+ This is an internal dialect method. Applications should use
1471
+ :meth:`_engine.Inspector.get_view_names`.
1472
+
1473
+ :param schema: schema name to query, if not the default schema.
1474
+
1475
+ """
1476
+
1477
+ raise NotImplementedError()
1478
+
1479
+ def get_materialized_view_names(
1480
+ self, connection: Connection, schema: Optional[str] = None, **kw: Any
1481
+ ) -> List[str]:
1482
+ """Return a list of all materialized view names available in the
1483
+ database.
1484
+
1485
+ This is an internal dialect method. Applications should use
1486
+ :meth:`_engine.Inspector.get_materialized_view_names`.
1487
+
1488
+ :param schema: schema name to query, if not the default schema.
1489
+
1490
+ .. versionadded:: 2.0
1491
+
1492
+ """
1493
+
1494
+ raise NotImplementedError()
1495
+
1496
+ def get_sequence_names(
1497
+ self, connection: Connection, schema: Optional[str] = None, **kw: Any
1498
+ ) -> List[str]:
1499
+ """Return a list of all sequence names available in the database.
1500
+
1501
+ This is an internal dialect method. Applications should use
1502
+ :meth:`_engine.Inspector.get_sequence_names`.
1503
+
1504
+ :param schema: schema name to query, if not the default schema.
1505
+
1506
+ .. versionadded:: 1.4
1507
+ """
1508
+
1509
+ raise NotImplementedError()
1510
+
1511
+ def get_temp_view_names(
1512
+ self, connection: Connection, schema: Optional[str] = None, **kw: Any
1513
+ ) -> List[str]:
1514
+ """Return a list of temporary view names on the given connection,
1515
+ if supported by the underlying backend.
1516
+
1517
+ This is an internal dialect method. Applications should use
1518
+ :meth:`_engine.Inspector.get_temp_view_names`.
1519
+
1520
+ """
1521
+
1522
+ raise NotImplementedError()
1523
+
1524
+ def get_schema_names(self, connection: Connection, **kw: Any) -> List[str]:
1525
+ """Return a list of all schema names available in the database.
1526
+
1527
+ This is an internal dialect method. Applications should use
1528
+ :meth:`_engine.Inspector.get_schema_names`.
1529
+ """
1530
+ raise NotImplementedError()
1531
+
1532
+ def get_view_definition(
1533
+ self,
1534
+ connection: Connection,
1535
+ view_name: str,
1536
+ schema: Optional[str] = None,
1537
+ **kw: Any,
1538
+ ) -> str:
1539
+ """Return plain or materialized view definition.
1540
+
1541
+ This is an internal dialect method. Applications should use
1542
+ :meth:`_engine.Inspector.get_view_definition`.
1543
+
1544
+ Given a :class:`_engine.Connection`, a string
1545
+ ``view_name``, and an optional string ``schema``, return the view
1546
+ definition.
1547
+ """
1548
+
1549
+ raise NotImplementedError()
1550
+
1551
+ def get_indexes(
1552
+ self,
1553
+ connection: Connection,
1554
+ table_name: str,
1555
+ schema: Optional[str] = None,
1556
+ **kw: Any,
1557
+ ) -> List[ReflectedIndex]:
1558
+ """Return information about indexes in ``table_name``.
1559
+
1560
+ Given a :class:`_engine.Connection`, a string
1561
+ ``table_name`` and an optional string ``schema``, return index
1562
+ information as a list of dictionaries corresponding to the
1563
+ :class:`.ReflectedIndex` dictionary.
1564
+
1565
+ This is an internal dialect method. Applications should use
1566
+ :meth:`.Inspector.get_indexes`.
1567
+ """
1568
+
1569
+ raise NotImplementedError()
1570
+
1571
+ def get_multi_indexes(
1572
+ self,
1573
+ connection: Connection,
1574
+ *,
1575
+ schema: Optional[str] = None,
1576
+ filter_names: Optional[Collection[str]] = None,
1577
+ **kw: Any,
1578
+ ) -> Iterable[Tuple[TableKey, List[ReflectedIndex]]]:
1579
+ """Return information about indexes in in all tables
1580
+ in the given ``schema``.
1581
+
1582
+ This is an internal dialect method. Applications should use
1583
+ :meth:`.Inspector.get_multi_indexes`.
1584
+
1585
+ .. note:: The :class:`_engine.DefaultDialect` provides a default
1586
+ implementation that will call the single table method for
1587
+ each object returned by :meth:`Dialect.get_table_names`,
1588
+ :meth:`Dialect.get_view_names` or
1589
+ :meth:`Dialect.get_materialized_view_names` depending on the
1590
+ provided ``kind``. Dialects that want to support a faster
1591
+ implementation should implement this method.
1592
+
1593
+ .. versionadded:: 2.0
1594
+
1595
+ """
1596
+
1597
+ raise NotImplementedError()
1598
+
1599
+ def get_unique_constraints(
1600
+ self,
1601
+ connection: Connection,
1602
+ table_name: str,
1603
+ schema: Optional[str] = None,
1604
+ **kw: Any,
1605
+ ) -> List[ReflectedUniqueConstraint]:
1606
+ r"""Return information about unique constraints in ``table_name``.
1607
+
1608
+ Given a string ``table_name`` and an optional string ``schema``, return
1609
+ unique constraint information as a list of dicts corresponding
1610
+ to the :class:`.ReflectedUniqueConstraint` dictionary.
1611
+
1612
+ This is an internal dialect method. Applications should use
1613
+ :meth:`.Inspector.get_unique_constraints`.
1614
+ """
1615
+
1616
+ raise NotImplementedError()
1617
+
1618
+ def get_multi_unique_constraints(
1619
+ self,
1620
+ connection: Connection,
1621
+ *,
1622
+ schema: Optional[str] = None,
1623
+ filter_names: Optional[Collection[str]] = None,
1624
+ **kw: Any,
1625
+ ) -> Iterable[Tuple[TableKey, List[ReflectedUniqueConstraint]]]:
1626
+ """Return information about unique constraints in all tables
1627
+ in the given ``schema``.
1628
+
1629
+ This is an internal dialect method. Applications should use
1630
+ :meth:`.Inspector.get_multi_unique_constraints`.
1631
+
1632
+ .. note:: The :class:`_engine.DefaultDialect` provides a default
1633
+ implementation that will call the single table method for
1634
+ each object returned by :meth:`Dialect.get_table_names`,
1635
+ :meth:`Dialect.get_view_names` or
1636
+ :meth:`Dialect.get_materialized_view_names` depending on the
1637
+ provided ``kind``. Dialects that want to support a faster
1638
+ implementation should implement this method.
1639
+
1640
+ .. versionadded:: 2.0
1641
+
1642
+ """
1643
+
1644
+ raise NotImplementedError()
1645
+
1646
+ def get_check_constraints(
1647
+ self,
1648
+ connection: Connection,
1649
+ table_name: str,
1650
+ schema: Optional[str] = None,
1651
+ **kw: Any,
1652
+ ) -> List[ReflectedCheckConstraint]:
1653
+ r"""Return information about check constraints in ``table_name``.
1654
+
1655
+ Given a string ``table_name`` and an optional string ``schema``, return
1656
+ check constraint information as a list of dicts corresponding
1657
+ to the :class:`.ReflectedCheckConstraint` dictionary.
1658
+
1659
+ This is an internal dialect method. Applications should use
1660
+ :meth:`.Inspector.get_check_constraints`.
1661
+
1662
+ """
1663
+
1664
+ raise NotImplementedError()
1665
+
1666
+ def get_multi_check_constraints(
1667
+ self,
1668
+ connection: Connection,
1669
+ *,
1670
+ schema: Optional[str] = None,
1671
+ filter_names: Optional[Collection[str]] = None,
1672
+ **kw: Any,
1673
+ ) -> Iterable[Tuple[TableKey, List[ReflectedCheckConstraint]]]:
1674
+ """Return information about check constraints in all tables
1675
+ in the given ``schema``.
1676
+
1677
+ This is an internal dialect method. Applications should use
1678
+ :meth:`.Inspector.get_multi_check_constraints`.
1679
+
1680
+ .. note:: The :class:`_engine.DefaultDialect` provides a default
1681
+ implementation that will call the single table method for
1682
+ each object returned by :meth:`Dialect.get_table_names`,
1683
+ :meth:`Dialect.get_view_names` or
1684
+ :meth:`Dialect.get_materialized_view_names` depending on the
1685
+ provided ``kind``. Dialects that want to support a faster
1686
+ implementation should implement this method.
1687
+
1688
+ .. versionadded:: 2.0
1689
+
1690
+ """
1691
+
1692
+ raise NotImplementedError()
1693
+
1694
+ def get_table_options(
1695
+ self,
1696
+ connection: Connection,
1697
+ table_name: str,
1698
+ schema: Optional[str] = None,
1699
+ **kw: Any,
1700
+ ) -> Dict[str, Any]:
1701
+ """Return a dictionary of options specified when ``table_name``
1702
+ was created.
1703
+
1704
+ This is an internal dialect method. Applications should use
1705
+ :meth:`_engine.Inspector.get_table_options`.
1706
+ """
1707
+ raise NotImplementedError()
1708
+
1709
+ def get_multi_table_options(
1710
+ self,
1711
+ connection: Connection,
1712
+ *,
1713
+ schema: Optional[str] = None,
1714
+ filter_names: Optional[Collection[str]] = None,
1715
+ **kw: Any,
1716
+ ) -> Iterable[Tuple[TableKey, Dict[str, Any]]]:
1717
+ """Return a dictionary of options specified when the tables in the
1718
+ given schema were created.
1719
+
1720
+ This is an internal dialect method. Applications should use
1721
+ :meth:`_engine.Inspector.get_multi_table_options`.
1722
+
1723
+ .. note:: The :class:`_engine.DefaultDialect` provides a default
1724
+ implementation that will call the single table method for
1725
+ each object returned by :meth:`Dialect.get_table_names`,
1726
+ :meth:`Dialect.get_view_names` or
1727
+ :meth:`Dialect.get_materialized_view_names` depending on the
1728
+ provided ``kind``. Dialects that want to support a faster
1729
+ implementation should implement this method.
1730
+
1731
+ .. versionadded:: 2.0
1732
+
1733
+ """
1734
+ raise NotImplementedError()
1735
+
1736
+ def get_table_comment(
1737
+ self,
1738
+ connection: Connection,
1739
+ table_name: str,
1740
+ schema: Optional[str] = None,
1741
+ **kw: Any,
1742
+ ) -> ReflectedTableComment:
1743
+ r"""Return the "comment" for the table identified by ``table_name``.
1744
+
1745
+ Given a string ``table_name`` and an optional string ``schema``, return
1746
+ table comment information as a dictionary corresponding to the
1747
+ :class:`.ReflectedTableComment` dictionary.
1748
+
1749
+ This is an internal dialect method. Applications should use
1750
+ :meth:`.Inspector.get_table_comment`.
1751
+
1752
+ :raise: ``NotImplementedError`` for dialects that don't support
1753
+ comments.
1754
+
1755
+ .. versionadded:: 1.2
1756
+
1757
+ """
1758
+
1759
+ raise NotImplementedError()
1760
+
1761
+ def get_multi_table_comment(
1762
+ self,
1763
+ connection: Connection,
1764
+ *,
1765
+ schema: Optional[str] = None,
1766
+ filter_names: Optional[Collection[str]] = None,
1767
+ **kw: Any,
1768
+ ) -> Iterable[Tuple[TableKey, ReflectedTableComment]]:
1769
+ """Return information about the table comment in all tables
1770
+ in the given ``schema``.
1771
+
1772
+ This is an internal dialect method. Applications should use
1773
+ :meth:`_engine.Inspector.get_multi_table_comment`.
1774
+
1775
+ .. note:: The :class:`_engine.DefaultDialect` provides a default
1776
+ implementation that will call the single table method for
1777
+ each object returned by :meth:`Dialect.get_table_names`,
1778
+ :meth:`Dialect.get_view_names` or
1779
+ :meth:`Dialect.get_materialized_view_names` depending on the
1780
+ provided ``kind``. Dialects that want to support a faster
1781
+ implementation should implement this method.
1782
+
1783
+ .. versionadded:: 2.0
1784
+
1785
+ """
1786
+
1787
+ raise NotImplementedError()
1788
+
1789
+ def normalize_name(self, name: str) -> str:
1790
+ """convert the given name to lowercase if it is detected as
1791
+ case insensitive.
1792
+
1793
+ This method is only used if the dialect defines
1794
+ requires_name_normalize=True.
1795
+
1796
+ """
1797
+ raise NotImplementedError()
1798
+
1799
+ def denormalize_name(self, name: str) -> str:
1800
+ """convert the given name to a case insensitive identifier
1801
+ for the backend if it is an all-lowercase name.
1802
+
1803
+ This method is only used if the dialect defines
1804
+ requires_name_normalize=True.
1805
+
1806
+ """
1807
+ raise NotImplementedError()
1808
+
1809
+ def has_table(
1810
+ self,
1811
+ connection: Connection,
1812
+ table_name: str,
1813
+ schema: Optional[str] = None,
1814
+ **kw: Any,
1815
+ ) -> bool:
1816
+ """For internal dialect use, check the existence of a particular table
1817
+ or view in the database.
1818
+
1819
+ Given a :class:`_engine.Connection` object, a string table_name and
1820
+ optional schema name, return True if the given table exists in the
1821
+ database, False otherwise.
1822
+
1823
+ This method serves as the underlying implementation of the
1824
+ public facing :meth:`.Inspector.has_table` method, and is also used
1825
+ internally to implement the "checkfirst" behavior for methods like
1826
+ :meth:`_schema.Table.create` and :meth:`_schema.MetaData.create_all`.
1827
+
1828
+ .. note:: This method is used internally by SQLAlchemy, and is
1829
+ published so that third-party dialects may provide an
1830
+ implementation. It is **not** the public API for checking for table
1831
+ presence. Please use the :meth:`.Inspector.has_table` method.
1832
+
1833
+ .. versionchanged:: 2.0:: :meth:`_engine.Dialect.has_table` now
1834
+ formally supports checking for additional table-like objects:
1835
+
1836
+ * any type of views (plain or materialized)
1837
+ * temporary tables of any kind
1838
+
1839
+ Previously, these two checks were not formally specified and
1840
+ different dialects would vary in their behavior. The dialect
1841
+ testing suite now includes tests for all of these object types,
1842
+ and dialects to the degree that the backing database supports views
1843
+ or temporary tables should seek to support locating these objects
1844
+ for full compliance.
1845
+
1846
+ """
1847
+
1848
+ raise NotImplementedError()
1849
+
1850
+ def has_index(
1851
+ self,
1852
+ connection: Connection,
1853
+ table_name: str,
1854
+ index_name: str,
1855
+ schema: Optional[str] = None,
1856
+ **kw: Any,
1857
+ ) -> bool:
1858
+ """Check the existence of a particular index name in the database.
1859
+
1860
+ Given a :class:`_engine.Connection` object, a string
1861
+ ``table_name`` and string index name, return ``True`` if an index of
1862
+ the given name on the given table exists, ``False`` otherwise.
1863
+
1864
+ The :class:`.DefaultDialect` implements this in terms of the
1865
+ :meth:`.Dialect.has_table` and :meth:`.Dialect.get_indexes` methods,
1866
+ however dialects can implement a more performant version.
1867
+
1868
+ This is an internal dialect method. Applications should use
1869
+ :meth:`_engine.Inspector.has_index`.
1870
+
1871
+ .. versionadded:: 1.4
1872
+
1873
+ """
1874
+
1875
+ raise NotImplementedError()
1876
+
1877
+ def has_sequence(
1878
+ self,
1879
+ connection: Connection,
1880
+ sequence_name: str,
1881
+ schema: Optional[str] = None,
1882
+ **kw: Any,
1883
+ ) -> bool:
1884
+ """Check the existence of a particular sequence in the database.
1885
+
1886
+ Given a :class:`_engine.Connection` object and a string
1887
+ `sequence_name`, return ``True`` if the given sequence exists in
1888
+ the database, ``False`` otherwise.
1889
+
1890
+ This is an internal dialect method. Applications should use
1891
+ :meth:`_engine.Inspector.has_sequence`.
1892
+ """
1893
+
1894
+ raise NotImplementedError()
1895
+
1896
+ def has_schema(
1897
+ self, connection: Connection, schema_name: str, **kw: Any
1898
+ ) -> bool:
1899
+ """Check the existence of a particular schema name in the database.
1900
+
1901
+ Given a :class:`_engine.Connection` object, a string
1902
+ ``schema_name``, return ``True`` if a schema of the
1903
+ given exists, ``False`` otherwise.
1904
+
1905
+ The :class:`.DefaultDialect` implements this by checking
1906
+ the presence of ``schema_name`` among the schemas returned by
1907
+ :meth:`.Dialect.get_schema_names`,
1908
+ however dialects can implement a more performant version.
1909
+
1910
+ This is an internal dialect method. Applications should use
1911
+ :meth:`_engine.Inspector.has_schema`.
1912
+
1913
+ .. versionadded:: 2.0
1914
+
1915
+ """
1916
+
1917
+ raise NotImplementedError()
1918
+
1919
+ def _get_server_version_info(self, connection: Connection) -> Any:
1920
+ """Retrieve the server version info from the given connection.
1921
+
1922
+ This is used by the default implementation to populate the
1923
+ "server_version_info" attribute and is called exactly
1924
+ once upon first connect.
1925
+
1926
+ """
1927
+
1928
+ raise NotImplementedError()
1929
+
1930
+ def _get_default_schema_name(self, connection: Connection) -> str:
1931
+ """Return the string name of the currently selected schema from
1932
+ the given connection.
1933
+
1934
+ This is used by the default implementation to populate the
1935
+ "default_schema_name" attribute and is called exactly
1936
+ once upon first connect.
1937
+
1938
+ """
1939
+
1940
+ raise NotImplementedError()
1941
+
1942
+ def do_begin(self, dbapi_connection: PoolProxiedConnection) -> None:
1943
+ """Provide an implementation of ``connection.begin()``, given a
1944
+ DB-API connection.
1945
+
1946
+ The DBAPI has no dedicated "begin" method and it is expected
1947
+ that transactions are implicit. This hook is provided for those
1948
+ DBAPIs that might need additional help in this area.
1949
+
1950
+ :param dbapi_connection: a DBAPI connection, typically
1951
+ proxied within a :class:`.ConnectionFairy`.
1952
+
1953
+ """
1954
+
1955
+ raise NotImplementedError()
1956
+
1957
+ def do_rollback(self, dbapi_connection: PoolProxiedConnection) -> None:
1958
+ """Provide an implementation of ``connection.rollback()``, given
1959
+ a DB-API connection.
1960
+
1961
+ :param dbapi_connection: a DBAPI connection, typically
1962
+ proxied within a :class:`.ConnectionFairy`.
1963
+
1964
+ """
1965
+
1966
+ raise NotImplementedError()
1967
+
1968
+ def do_commit(self, dbapi_connection: PoolProxiedConnection) -> None:
1969
+ """Provide an implementation of ``connection.commit()``, given a
1970
+ DB-API connection.
1971
+
1972
+ :param dbapi_connection: a DBAPI connection, typically
1973
+ proxied within a :class:`.ConnectionFairy`.
1974
+
1975
+ """
1976
+
1977
+ raise NotImplementedError()
1978
+
1979
+ def do_terminate(self, dbapi_connection: DBAPIConnection) -> None:
1980
+ """Provide an implementation of ``connection.close()`` that tries as
1981
+ much as possible to not block, given a DBAPI
1982
+ connection.
1983
+
1984
+ In the vast majority of cases this just calls .close(), however
1985
+ for some asyncio dialects may call upon different API features.
1986
+
1987
+ This hook is called by the :class:`_pool.Pool`
1988
+ when a connection is being recycled or has been invalidated.
1989
+
1990
+ .. versionadded:: 1.4.41
1991
+
1992
+ """
1993
+
1994
+ raise NotImplementedError()
1995
+
1996
+ def do_close(self, dbapi_connection: DBAPIConnection) -> None:
1997
+ """Provide an implementation of ``connection.close()``, given a DBAPI
1998
+ connection.
1999
+
2000
+ This hook is called by the :class:`_pool.Pool`
2001
+ when a connection has been
2002
+ detached from the pool, or is being returned beyond the normal
2003
+ capacity of the pool.
2004
+
2005
+ """
2006
+
2007
+ raise NotImplementedError()
2008
+
2009
+ def _do_ping_w_event(self, dbapi_connection: DBAPIConnection) -> bool:
2010
+ raise NotImplementedError()
2011
+
2012
+ def do_ping(self, dbapi_connection: DBAPIConnection) -> bool:
2013
+ """ping the DBAPI connection and return True if the connection is
2014
+ usable."""
2015
+ raise NotImplementedError()
2016
+
2017
+ def do_set_input_sizes(
2018
+ self,
2019
+ cursor: DBAPICursor,
2020
+ list_of_tuples: _GenericSetInputSizesType,
2021
+ context: ExecutionContext,
2022
+ ) -> Any:
2023
+ """invoke the cursor.setinputsizes() method with appropriate arguments
2024
+
2025
+ This hook is called if the :attr:`.Dialect.bind_typing` attribute is
2026
+ set to the
2027
+ :attr:`.BindTyping.SETINPUTSIZES` value.
2028
+ Parameter data is passed in a list of tuples (paramname, dbtype,
2029
+ sqltype), where ``paramname`` is the key of the parameter in the
2030
+ statement, ``dbtype`` is the DBAPI datatype and ``sqltype`` is the
2031
+ SQLAlchemy type. The order of tuples is in the correct parameter order.
2032
+
2033
+ .. versionadded:: 1.4
2034
+
2035
+ .. versionchanged:: 2.0 - setinputsizes mode is now enabled by
2036
+ setting :attr:`.Dialect.bind_typing` to
2037
+ :attr:`.BindTyping.SETINPUTSIZES`. Dialects which accept
2038
+ a ``use_setinputsizes`` parameter should set this value
2039
+ appropriately.
2040
+
2041
+
2042
+ """
2043
+ raise NotImplementedError()
2044
+
2045
+ def create_xid(self) -> Any:
2046
+ """Create a two-phase transaction ID.
2047
+
2048
+ This id will be passed to do_begin_twophase(),
2049
+ do_rollback_twophase(), do_commit_twophase(). Its format is
2050
+ unspecified.
2051
+ """
2052
+
2053
+ raise NotImplementedError()
2054
+
2055
+ def do_savepoint(self, connection: Connection, name: str) -> None:
2056
+ """Create a savepoint with the given name.
2057
+
2058
+ :param connection: a :class:`_engine.Connection`.
2059
+ :param name: savepoint name.
2060
+
2061
+ """
2062
+
2063
+ raise NotImplementedError()
2064
+
2065
+ def do_rollback_to_savepoint(
2066
+ self, connection: Connection, name: str
2067
+ ) -> None:
2068
+ """Rollback a connection to the named savepoint.
2069
+
2070
+ :param connection: a :class:`_engine.Connection`.
2071
+ :param name: savepoint name.
2072
+
2073
+ """
2074
+
2075
+ raise NotImplementedError()
2076
+
2077
+ def do_release_savepoint(self, connection: Connection, name: str) -> None:
2078
+ """Release the named savepoint on a connection.
2079
+
2080
+ :param connection: a :class:`_engine.Connection`.
2081
+ :param name: savepoint name.
2082
+ """
2083
+
2084
+ raise NotImplementedError()
2085
+
2086
+ def do_begin_twophase(self, connection: Connection, xid: Any) -> None:
2087
+ """Begin a two phase transaction on the given connection.
2088
+
2089
+ :param connection: a :class:`_engine.Connection`.
2090
+ :param xid: xid
2091
+
2092
+ """
2093
+
2094
+ raise NotImplementedError()
2095
+
2096
+ def do_prepare_twophase(self, connection: Connection, xid: Any) -> None:
2097
+ """Prepare a two phase transaction on the given connection.
2098
+
2099
+ :param connection: a :class:`_engine.Connection`.
2100
+ :param xid: xid
2101
+
2102
+ """
2103
+
2104
+ raise NotImplementedError()
2105
+
2106
+ def do_rollback_twophase(
2107
+ self,
2108
+ connection: Connection,
2109
+ xid: Any,
2110
+ is_prepared: bool = True,
2111
+ recover: bool = False,
2112
+ ) -> None:
2113
+ """Rollback a two phase transaction on the given connection.
2114
+
2115
+ :param connection: a :class:`_engine.Connection`.
2116
+ :param xid: xid
2117
+ :param is_prepared: whether or not
2118
+ :meth:`.TwoPhaseTransaction.prepare` was called.
2119
+ :param recover: if the recover flag was passed.
2120
+
2121
+ """
2122
+
2123
+ raise NotImplementedError()
2124
+
2125
+ def do_commit_twophase(
2126
+ self,
2127
+ connection: Connection,
2128
+ xid: Any,
2129
+ is_prepared: bool = True,
2130
+ recover: bool = False,
2131
+ ) -> None:
2132
+ """Commit a two phase transaction on the given connection.
2133
+
2134
+
2135
+ :param connection: a :class:`_engine.Connection`.
2136
+ :param xid: xid
2137
+ :param is_prepared: whether or not
2138
+ :meth:`.TwoPhaseTransaction.prepare` was called.
2139
+ :param recover: if the recover flag was passed.
2140
+
2141
+ """
2142
+
2143
+ raise NotImplementedError()
2144
+
2145
+ def do_recover_twophase(self, connection: Connection) -> List[Any]:
2146
+ """Recover list of uncommitted prepared two phase transaction
2147
+ identifiers on the given connection.
2148
+
2149
+ :param connection: a :class:`_engine.Connection`.
2150
+
2151
+ """
2152
+
2153
+ raise NotImplementedError()
2154
+
2155
+ def _deliver_insertmanyvalues_batches(
2156
+ self,
2157
+ connection: Connection,
2158
+ cursor: DBAPICursor,
2159
+ statement: str,
2160
+ parameters: _DBAPIMultiExecuteParams,
2161
+ generic_setinputsizes: Optional[_GenericSetInputSizesType],
2162
+ context: ExecutionContext,
2163
+ ) -> Iterator[_InsertManyValuesBatch]:
2164
+ """convert executemany parameters for an INSERT into an iterator
2165
+ of statement/single execute values, used by the insertmanyvalues
2166
+ feature.
2167
+
2168
+ """
2169
+ raise NotImplementedError()
2170
+
2171
+ def do_executemany(
2172
+ self,
2173
+ cursor: DBAPICursor,
2174
+ statement: str,
2175
+ parameters: _DBAPIMultiExecuteParams,
2176
+ context: Optional[ExecutionContext] = None,
2177
+ ) -> None:
2178
+ """Provide an implementation of ``cursor.executemany(statement,
2179
+ parameters)``."""
2180
+
2181
+ raise NotImplementedError()
2182
+
2183
+ def do_execute(
2184
+ self,
2185
+ cursor: DBAPICursor,
2186
+ statement: str,
2187
+ parameters: Optional[_DBAPISingleExecuteParams],
2188
+ context: Optional[ExecutionContext] = None,
2189
+ ) -> None:
2190
+ """Provide an implementation of ``cursor.execute(statement,
2191
+ parameters)``."""
2192
+
2193
+ raise NotImplementedError()
2194
+
2195
+ def do_execute_no_params(
2196
+ self,
2197
+ cursor: DBAPICursor,
2198
+ statement: str,
2199
+ context: Optional[ExecutionContext] = None,
2200
+ ) -> None:
2201
+ """Provide an implementation of ``cursor.execute(statement)``.
2202
+
2203
+ The parameter collection should not be sent.
2204
+
2205
+ """
2206
+
2207
+ raise NotImplementedError()
2208
+
2209
+ def is_disconnect(
2210
+ self,
2211
+ e: Exception,
2212
+ connection: Optional[Union[PoolProxiedConnection, DBAPIConnection]],
2213
+ cursor: Optional[DBAPICursor],
2214
+ ) -> bool:
2215
+ """Return True if the given DB-API error indicates an invalid
2216
+ connection"""
2217
+
2218
+ raise NotImplementedError()
2219
+
2220
+ def connect(self, *cargs: Any, **cparams: Any) -> DBAPIConnection:
2221
+ r"""Establish a connection using this dialect's DBAPI.
2222
+
2223
+ The default implementation of this method is::
2224
+
2225
+ def connect(self, *cargs, **cparams):
2226
+ return self.dbapi.connect(*cargs, **cparams)
2227
+
2228
+ The ``*cargs, **cparams`` parameters are generated directly
2229
+ from this dialect's :meth:`.Dialect.create_connect_args` method.
2230
+
2231
+ This method may be used for dialects that need to perform programmatic
2232
+ per-connection steps when a new connection is procured from the
2233
+ DBAPI.
2234
+
2235
+
2236
+ :param \*cargs: positional parameters returned from the
2237
+ :meth:`.Dialect.create_connect_args` method
2238
+
2239
+ :param \*\*cparams: keyword parameters returned from the
2240
+ :meth:`.Dialect.create_connect_args` method.
2241
+
2242
+ :return: a DBAPI connection, typically from the :pep:`249` module
2243
+ level ``.connect()`` function.
2244
+
2245
+ .. seealso::
2246
+
2247
+ :meth:`.Dialect.create_connect_args`
2248
+
2249
+ :meth:`.Dialect.on_connect`
2250
+
2251
+ """
2252
+ raise NotImplementedError()
2253
+
2254
+ def on_connect_url(self, url: URL) -> Optional[Callable[[Any], Any]]:
2255
+ """return a callable which sets up a newly created DBAPI connection.
2256
+
2257
+ This method is a new hook that supersedes the
2258
+ :meth:`_engine.Dialect.on_connect` method when implemented by a
2259
+ dialect. When not implemented by a dialect, it invokes the
2260
+ :meth:`_engine.Dialect.on_connect` method directly to maintain
2261
+ compatibility with existing dialects. There is no deprecation
2262
+ for :meth:`_engine.Dialect.on_connect` expected.
2263
+
2264
+ The callable should accept a single argument "conn" which is the
2265
+ DBAPI connection itself. The inner callable has no
2266
+ return value.
2267
+
2268
+ E.g.::
2269
+
2270
+ class MyDialect(default.DefaultDialect):
2271
+ # ...
2272
+
2273
+ def on_connect_url(self, url):
2274
+ def do_on_connect(connection):
2275
+ connection.execute("SET SPECIAL FLAGS etc")
2276
+
2277
+ return do_on_connect
2278
+
2279
+ This is used to set dialect-wide per-connection options such as
2280
+ isolation modes, Unicode modes, etc.
2281
+
2282
+ This method differs from :meth:`_engine.Dialect.on_connect` in that
2283
+ it is passed the :class:`_engine.URL` object that's relevant to the
2284
+ connect args. Normally the only way to get this is from the
2285
+ :meth:`_engine.Dialect.on_connect` hook is to look on the
2286
+ :class:`_engine.Engine` itself, however this URL object may have been
2287
+ replaced by plugins.
2288
+
2289
+ .. note::
2290
+
2291
+ The default implementation of
2292
+ :meth:`_engine.Dialect.on_connect_url` is to invoke the
2293
+ :meth:`_engine.Dialect.on_connect` method. Therefore if a dialect
2294
+ implements this method, the :meth:`_engine.Dialect.on_connect`
2295
+ method **will not be called** unless the overriding dialect calls
2296
+ it directly from here.
2297
+
2298
+ .. versionadded:: 1.4.3 added :meth:`_engine.Dialect.on_connect_url`
2299
+ which normally calls into :meth:`_engine.Dialect.on_connect`.
2300
+
2301
+ :param url: a :class:`_engine.URL` object representing the
2302
+ :class:`_engine.URL` that was passed to the
2303
+ :meth:`_engine.Dialect.create_connect_args` method.
2304
+
2305
+ :return: a callable that accepts a single DBAPI connection as an
2306
+ argument, or None.
2307
+
2308
+ .. seealso::
2309
+
2310
+ :meth:`_engine.Dialect.on_connect`
2311
+
2312
+ """
2313
+ return self.on_connect()
2314
+
2315
+ def on_connect(self) -> Optional[Callable[[Any], Any]]:
2316
+ """return a callable which sets up a newly created DBAPI connection.
2317
+
2318
+ The callable should accept a single argument "conn" which is the
2319
+ DBAPI connection itself. The inner callable has no
2320
+ return value.
2321
+
2322
+ E.g.::
2323
+
2324
+ class MyDialect(default.DefaultDialect):
2325
+ # ...
2326
+
2327
+ def on_connect(self):
2328
+ def do_on_connect(connection):
2329
+ connection.execute("SET SPECIAL FLAGS etc")
2330
+
2331
+ return do_on_connect
2332
+
2333
+ This is used to set dialect-wide per-connection options such as
2334
+ isolation modes, Unicode modes, etc.
2335
+
2336
+ The "do_on_connect" callable is invoked by using the
2337
+ :meth:`_events.PoolEvents.connect` event
2338
+ hook, then unwrapping the DBAPI connection and passing it into the
2339
+ callable.
2340
+
2341
+ .. versionchanged:: 1.4 the on_connect hook is no longer called twice
2342
+ for the first connection of a dialect. The on_connect hook is still
2343
+ called before the :meth:`_engine.Dialect.initialize` method however.
2344
+
2345
+ .. versionchanged:: 1.4.3 the on_connect hook is invoked from a new
2346
+ method on_connect_url that passes the URL that was used to create
2347
+ the connect args. Dialects can implement on_connect_url instead
2348
+ of on_connect if they need the URL object that was used for the
2349
+ connection in order to get additional context.
2350
+
2351
+ If None is returned, no event listener is generated.
2352
+
2353
+ :return: a callable that accepts a single DBAPI connection as an
2354
+ argument, or None.
2355
+
2356
+ .. seealso::
2357
+
2358
+ :meth:`.Dialect.connect` - allows the DBAPI ``connect()`` sequence
2359
+ itself to be controlled.
2360
+
2361
+ :meth:`.Dialect.on_connect_url` - supersedes
2362
+ :meth:`.Dialect.on_connect` to also receive the
2363
+ :class:`_engine.URL` object in context.
2364
+
2365
+ """
2366
+ return None
2367
+
2368
+ def reset_isolation_level(self, dbapi_connection: DBAPIConnection) -> None:
2369
+ """Given a DBAPI connection, revert its isolation to the default.
2370
+
2371
+ Note that this is a dialect-level method which is used as part
2372
+ of the implementation of the :class:`_engine.Connection` and
2373
+ :class:`_engine.Engine`
2374
+ isolation level facilities; these APIs should be preferred for
2375
+ most typical use cases.
2376
+
2377
+ .. seealso::
2378
+
2379
+ :meth:`_engine.Connection.get_isolation_level`
2380
+ - view current level
2381
+
2382
+ :attr:`_engine.Connection.default_isolation_level`
2383
+ - view default level
2384
+
2385
+ :paramref:`.Connection.execution_options.isolation_level` -
2386
+ set per :class:`_engine.Connection` isolation level
2387
+
2388
+ :paramref:`_sa.create_engine.isolation_level` -
2389
+ set per :class:`_engine.Engine` isolation level
2390
+
2391
+ """
2392
+
2393
+ raise NotImplementedError()
2394
+
2395
+ def set_isolation_level(
2396
+ self, dbapi_connection: DBAPIConnection, level: IsolationLevel
2397
+ ) -> None:
2398
+ """Given a DBAPI connection, set its isolation level.
2399
+
2400
+ Note that this is a dialect-level method which is used as part
2401
+ of the implementation of the :class:`_engine.Connection` and
2402
+ :class:`_engine.Engine`
2403
+ isolation level facilities; these APIs should be preferred for
2404
+ most typical use cases.
2405
+
2406
+ If the dialect also implements the
2407
+ :meth:`.Dialect.get_isolation_level_values` method, then the given
2408
+ level is guaranteed to be one of the string names within that sequence,
2409
+ and the method will not need to anticipate a lookup failure.
2410
+
2411
+ .. seealso::
2412
+
2413
+ :meth:`_engine.Connection.get_isolation_level`
2414
+ - view current level
2415
+
2416
+ :attr:`_engine.Connection.default_isolation_level`
2417
+ - view default level
2418
+
2419
+ :paramref:`.Connection.execution_options.isolation_level` -
2420
+ set per :class:`_engine.Connection` isolation level
2421
+
2422
+ :paramref:`_sa.create_engine.isolation_level` -
2423
+ set per :class:`_engine.Engine` isolation level
2424
+
2425
+ """
2426
+
2427
+ raise NotImplementedError()
2428
+
2429
+ def get_isolation_level(
2430
+ self, dbapi_connection: DBAPIConnection
2431
+ ) -> IsolationLevel:
2432
+ """Given a DBAPI connection, return its isolation level.
2433
+
2434
+ When working with a :class:`_engine.Connection` object,
2435
+ the corresponding
2436
+ DBAPI connection may be procured using the
2437
+ :attr:`_engine.Connection.connection` accessor.
2438
+
2439
+ Note that this is a dialect-level method which is used as part
2440
+ of the implementation of the :class:`_engine.Connection` and
2441
+ :class:`_engine.Engine` isolation level facilities;
2442
+ these APIs should be preferred for most typical use cases.
2443
+
2444
+
2445
+ .. seealso::
2446
+
2447
+ :meth:`_engine.Connection.get_isolation_level`
2448
+ - view current level
2449
+
2450
+ :attr:`_engine.Connection.default_isolation_level`
2451
+ - view default level
2452
+
2453
+ :paramref:`.Connection.execution_options.isolation_level` -
2454
+ set per :class:`_engine.Connection` isolation level
2455
+
2456
+ :paramref:`_sa.create_engine.isolation_level` -
2457
+ set per :class:`_engine.Engine` isolation level
2458
+
2459
+
2460
+ """
2461
+
2462
+ raise NotImplementedError()
2463
+
2464
+ def get_default_isolation_level(
2465
+ self, dbapi_conn: DBAPIConnection
2466
+ ) -> IsolationLevel:
2467
+ """Given a DBAPI connection, return its isolation level, or
2468
+ a default isolation level if one cannot be retrieved.
2469
+
2470
+ This method may only raise NotImplementedError and
2471
+ **must not raise any other exception**, as it is used implicitly upon
2472
+ first connect.
2473
+
2474
+ The method **must return a value** for a dialect that supports
2475
+ isolation level settings, as this level is what will be reverted
2476
+ towards when a per-connection isolation level change is made.
2477
+
2478
+ The method defaults to using the :meth:`.Dialect.get_isolation_level`
2479
+ method unless overridden by a dialect.
2480
+
2481
+ .. versionadded:: 1.3.22
2482
+
2483
+ """
2484
+ raise NotImplementedError()
2485
+
2486
+ def get_isolation_level_values(
2487
+ self, dbapi_conn: DBAPIConnection
2488
+ ) -> List[IsolationLevel]:
2489
+ """return a sequence of string isolation level names that are accepted
2490
+ by this dialect.
2491
+
2492
+ The available names should use the following conventions:
2493
+
2494
+ * use UPPERCASE names. isolation level methods will accept lowercase
2495
+ names but these are normalized into UPPERCASE before being passed
2496
+ along to the dialect.
2497
+ * separate words should be separated by spaces, not underscores, e.g.
2498
+ ``REPEATABLE READ``. isolation level names will have underscores
2499
+ converted to spaces before being passed along to the dialect.
2500
+ * The names for the four standard isolation names to the extent that
2501
+ they are supported by the backend should be ``READ UNCOMMITTED``
2502
+ ``READ COMMITTED``, ``REPEATABLE READ``, ``SERIALIZABLE``
2503
+ * if the dialect supports an autocommit option it should be provided
2504
+ using the isolation level name ``AUTOCOMMIT``.
2505
+ * Other isolation modes may also be present, provided that they
2506
+ are named in UPPERCASE and use spaces not underscores.
2507
+
2508
+ This function is used so that the default dialect can check that
2509
+ a given isolation level parameter is valid, else raises an
2510
+ :class:`_exc.ArgumentError`.
2511
+
2512
+ A DBAPI connection is passed to the method, in the unlikely event that
2513
+ the dialect needs to interrogate the connection itself to determine
2514
+ this list, however it is expected that most backends will return
2515
+ a hardcoded list of values. If the dialect supports "AUTOCOMMIT",
2516
+ that value should also be present in the sequence returned.
2517
+
2518
+ The method raises ``NotImplementedError`` by default. If a dialect
2519
+ does not implement this method, then the default dialect will not
2520
+ perform any checking on a given isolation level value before passing
2521
+ it onto the :meth:`.Dialect.set_isolation_level` method. This is
2522
+ to allow backwards-compatibility with third party dialects that may
2523
+ not yet be implementing this method.
2524
+
2525
+ .. versionadded:: 2.0
2526
+
2527
+ """
2528
+ raise NotImplementedError()
2529
+
2530
+ def _assert_and_set_isolation_level(
2531
+ self, dbapi_conn: DBAPIConnection, level: IsolationLevel
2532
+ ) -> None:
2533
+ raise NotImplementedError()
2534
+
2535
+ @classmethod
2536
+ def get_dialect_cls(cls, url: URL) -> Type[Dialect]:
2537
+ """Given a URL, return the :class:`.Dialect` that will be used.
2538
+
2539
+ This is a hook that allows an external plugin to provide functionality
2540
+ around an existing dialect, by allowing the plugin to be loaded
2541
+ from the url based on an entrypoint, and then the plugin returns
2542
+ the actual dialect to be used.
2543
+
2544
+ By default this just returns the cls.
2545
+
2546
+ """
2547
+ return cls
2548
+
2549
+ @classmethod
2550
+ def get_async_dialect_cls(cls, url: URL) -> Type[Dialect]:
2551
+ """Given a URL, return the :class:`.Dialect` that will be used by
2552
+ an async engine.
2553
+
2554
+ By default this is an alias of :meth:`.Dialect.get_dialect_cls` and
2555
+ just returns the cls. It may be used if a dialect provides
2556
+ both a sync and async version under the same name, like the
2557
+ ``psycopg`` driver.
2558
+
2559
+ .. versionadded:: 2
2560
+
2561
+ .. seealso::
2562
+
2563
+ :meth:`.Dialect.get_dialect_cls`
2564
+
2565
+ """
2566
+ return cls.get_dialect_cls(url)
2567
+
2568
+ @classmethod
2569
+ def load_provisioning(cls) -> None:
2570
+ """set up the provision.py module for this dialect.
2571
+
2572
+ For dialects that include a provision.py module that sets up
2573
+ provisioning followers, this method should initiate that process.
2574
+
2575
+ A typical implementation would be::
2576
+
2577
+ @classmethod
2578
+ def load_provisioning(cls):
2579
+ __import__("mydialect.provision")
2580
+
2581
+ The default method assumes a module named ``provision.py`` inside
2582
+ the owning package of the current dialect, based on the ``__module__``
2583
+ attribute::
2584
+
2585
+ @classmethod
2586
+ def load_provisioning(cls):
2587
+ package = ".".join(cls.__module__.split(".")[0:-1])
2588
+ try:
2589
+ __import__(package + ".provision")
2590
+ except ImportError:
2591
+ pass
2592
+
2593
+ .. versionadded:: 1.3.14
2594
+
2595
+ """
2596
+
2597
+ @classmethod
2598
+ def engine_created(cls, engine: Engine) -> None:
2599
+ """A convenience hook called before returning the final
2600
+ :class:`_engine.Engine`.
2601
+
2602
+ If the dialect returned a different class from the
2603
+ :meth:`.get_dialect_cls`
2604
+ method, then the hook is called on both classes, first on
2605
+ the dialect class returned by the :meth:`.get_dialect_cls` method and
2606
+ then on the class on which the method was called.
2607
+
2608
+ The hook should be used by dialects and/or wrappers to apply special
2609
+ events to the engine or its components. In particular, it allows
2610
+ a dialect-wrapping class to apply dialect-level events.
2611
+
2612
+ """
2613
+
2614
+ def get_driver_connection(self, connection: DBAPIConnection) -> Any:
2615
+ """Returns the connection object as returned by the external driver
2616
+ package.
2617
+
2618
+ For normal dialects that use a DBAPI compliant driver this call
2619
+ will just return the ``connection`` passed as argument.
2620
+ For dialects that instead adapt a non DBAPI compliant driver, like
2621
+ when adapting an asyncio driver, this call will return the
2622
+ connection-like object as returned by the driver.
2623
+
2624
+ .. versionadded:: 1.4.24
2625
+
2626
+ """
2627
+ raise NotImplementedError()
2628
+
2629
+ def set_engine_execution_options(
2630
+ self, engine: Engine, opts: CoreExecuteOptionsParameter
2631
+ ) -> None:
2632
+ """Establish execution options for a given engine.
2633
+
2634
+ This is implemented by :class:`.DefaultDialect` to establish
2635
+ event hooks for new :class:`.Connection` instances created
2636
+ by the given :class:`.Engine` which will then invoke the
2637
+ :meth:`.Dialect.set_connection_execution_options` method for that
2638
+ connection.
2639
+
2640
+ """
2641
+ raise NotImplementedError()
2642
+
2643
+ def set_connection_execution_options(
2644
+ self, connection: Connection, opts: CoreExecuteOptionsParameter
2645
+ ) -> None:
2646
+ """Establish execution options for a given connection.
2647
+
2648
+ This is implemented by :class:`.DefaultDialect` in order to implement
2649
+ the :paramref:`_engine.Connection.execution_options.isolation_level`
2650
+ execution option. Dialects can intercept various execution options
2651
+ which may need to modify state on a particular DBAPI connection.
2652
+
2653
+ .. versionadded:: 1.4
2654
+
2655
+ """
2656
+ raise NotImplementedError()
2657
+
2658
+ def get_dialect_pool_class(self, url: URL) -> Type[Pool]:
2659
+ """return a Pool class to use for a given URL"""
2660
+ raise NotImplementedError()
2661
+
2662
+
2663
+ class CreateEnginePlugin:
2664
+ """A set of hooks intended to augment the construction of an
2665
+ :class:`_engine.Engine` object based on entrypoint names in a URL.
2666
+
2667
+ The purpose of :class:`_engine.CreateEnginePlugin` is to allow third-party
2668
+ systems to apply engine, pool and dialect level event listeners without
2669
+ the need for the target application to be modified; instead, the plugin
2670
+ names can be added to the database URL. Target applications for
2671
+ :class:`_engine.CreateEnginePlugin` include:
2672
+
2673
+ * connection and SQL performance tools, e.g. which use events to track
2674
+ number of checkouts and/or time spent with statements
2675
+
2676
+ * connectivity plugins such as proxies
2677
+
2678
+ A rudimentary :class:`_engine.CreateEnginePlugin` that attaches a logger
2679
+ to an :class:`_engine.Engine` object might look like::
2680
+
2681
+
2682
+ import logging
2683
+
2684
+ from sqlalchemy.engine import CreateEnginePlugin
2685
+ from sqlalchemy import event
2686
+
2687
+ class LogCursorEventsPlugin(CreateEnginePlugin):
2688
+ def __init__(self, url, kwargs):
2689
+ # consume the parameter "log_cursor_logging_name" from the
2690
+ # URL query
2691
+ logging_name = url.query.get("log_cursor_logging_name", "log_cursor")
2692
+
2693
+ self.log = logging.getLogger(logging_name)
2694
+
2695
+ def update_url(self, url):
2696
+ "update the URL to one that no longer includes our parameters"
2697
+ return url.difference_update_query(["log_cursor_logging_name"])
2698
+
2699
+ def engine_created(self, engine):
2700
+ "attach an event listener after the new Engine is constructed"
2701
+ event.listen(engine, "before_cursor_execute", self._log_event)
2702
+
2703
+
2704
+ def _log_event(
2705
+ self,
2706
+ conn,
2707
+ cursor,
2708
+ statement,
2709
+ parameters,
2710
+ context,
2711
+ executemany):
2712
+
2713
+ self.log.info("Plugin logged cursor event: %s", statement)
2714
+
2715
+
2716
+
2717
+ Plugins are registered using entry points in a similar way as that
2718
+ of dialects::
2719
+
2720
+ entry_points={
2721
+ 'sqlalchemy.plugins': [
2722
+ 'log_cursor_plugin = myapp.plugins:LogCursorEventsPlugin'
2723
+ ]
2724
+
2725
+ A plugin that uses the above names would be invoked from a database
2726
+ URL as in::
2727
+
2728
+ from sqlalchemy import create_engine
2729
+
2730
+ engine = create_engine(
2731
+ "mysql+pymysql://scott:tiger@localhost/test?"
2732
+ "plugin=log_cursor_plugin&log_cursor_logging_name=mylogger"
2733
+ )
2734
+
2735
+ The ``plugin`` URL parameter supports multiple instances, so that a URL
2736
+ may specify multiple plugins; they are loaded in the order stated
2737
+ in the URL::
2738
+
2739
+ engine = create_engine(
2740
+ "mysql+pymysql://scott:tiger@localhost/test?"
2741
+ "plugin=plugin_one&plugin=plugin_twp&plugin=plugin_three")
2742
+
2743
+ The plugin names may also be passed directly to :func:`_sa.create_engine`
2744
+ using the :paramref:`_sa.create_engine.plugins` argument::
2745
+
2746
+ engine = create_engine(
2747
+ "mysql+pymysql://scott:tiger@localhost/test",
2748
+ plugins=["myplugin"])
2749
+
2750
+ .. versionadded:: 1.2.3 plugin names can also be specified
2751
+ to :func:`_sa.create_engine` as a list
2752
+
2753
+ A plugin may consume plugin-specific arguments from the
2754
+ :class:`_engine.URL` object as well as the ``kwargs`` dictionary, which is
2755
+ the dictionary of arguments passed to the :func:`_sa.create_engine`
2756
+ call. "Consuming" these arguments includes that they must be removed
2757
+ when the plugin initializes, so that the arguments are not passed along
2758
+ to the :class:`_engine.Dialect` constructor, where they will raise an
2759
+ :class:`_exc.ArgumentError` because they are not known by the dialect.
2760
+
2761
+ As of version 1.4 of SQLAlchemy, arguments should continue to be consumed
2762
+ from the ``kwargs`` dictionary directly, by removing the values with a
2763
+ method such as ``dict.pop``. Arguments from the :class:`_engine.URL` object
2764
+ should be consumed by implementing the
2765
+ :meth:`_engine.CreateEnginePlugin.update_url` method, returning a new copy
2766
+ of the :class:`_engine.URL` with plugin-specific parameters removed::
2767
+
2768
+ class MyPlugin(CreateEnginePlugin):
2769
+ def __init__(self, url, kwargs):
2770
+ self.my_argument_one = url.query['my_argument_one']
2771
+ self.my_argument_two = url.query['my_argument_two']
2772
+ self.my_argument_three = kwargs.pop('my_argument_three', None)
2773
+
2774
+ def update_url(self, url):
2775
+ return url.difference_update_query(
2776
+ ["my_argument_one", "my_argument_two"]
2777
+ )
2778
+
2779
+ Arguments like those illustrated above would be consumed from a
2780
+ :func:`_sa.create_engine` call such as::
2781
+
2782
+ from sqlalchemy import create_engine
2783
+
2784
+ engine = create_engine(
2785
+ "mysql+pymysql://scott:tiger@localhost/test?"
2786
+ "plugin=myplugin&my_argument_one=foo&my_argument_two=bar",
2787
+ my_argument_three='bat'
2788
+ )
2789
+
2790
+ .. versionchanged:: 1.4
2791
+
2792
+ The :class:`_engine.URL` object is now immutable; a
2793
+ :class:`_engine.CreateEnginePlugin` that needs to alter the
2794
+ :class:`_engine.URL` should implement the newly added
2795
+ :meth:`_engine.CreateEnginePlugin.update_url` method, which
2796
+ is invoked after the plugin is constructed.
2797
+
2798
+ For migration, construct the plugin in the following way, checking
2799
+ for the existence of the :meth:`_engine.CreateEnginePlugin.update_url`
2800
+ method to detect which version is running::
2801
+
2802
+ class MyPlugin(CreateEnginePlugin):
2803
+ def __init__(self, url, kwargs):
2804
+ if hasattr(CreateEnginePlugin, "update_url"):
2805
+ # detect the 1.4 API
2806
+ self.my_argument_one = url.query['my_argument_one']
2807
+ self.my_argument_two = url.query['my_argument_two']
2808
+ else:
2809
+ # detect the 1.3 and earlier API - mutate the
2810
+ # URL directly
2811
+ self.my_argument_one = url.query.pop('my_argument_one')
2812
+ self.my_argument_two = url.query.pop('my_argument_two')
2813
+
2814
+ self.my_argument_three = kwargs.pop('my_argument_three', None)
2815
+
2816
+ def update_url(self, url):
2817
+ # this method is only called in the 1.4 version
2818
+ return url.difference_update_query(
2819
+ ["my_argument_one", "my_argument_two"]
2820
+ )
2821
+
2822
+ .. seealso::
2823
+
2824
+ :ref:`change_5526` - overview of the :class:`_engine.URL` change which
2825
+ also includes notes regarding :class:`_engine.CreateEnginePlugin`.
2826
+
2827
+
2828
+ When the engine creation process completes and produces the
2829
+ :class:`_engine.Engine` object, it is again passed to the plugin via the
2830
+ :meth:`_engine.CreateEnginePlugin.engine_created` hook. In this hook, additional
2831
+ changes can be made to the engine, most typically involving setup of
2832
+ events (e.g. those defined in :ref:`core_event_toplevel`).
2833
+
2834
+ """ # noqa: E501
2835
+
2836
+ def __init__(self, url: URL, kwargs: Dict[str, Any]):
2837
+ """Construct a new :class:`.CreateEnginePlugin`.
2838
+
2839
+ The plugin object is instantiated individually for each call
2840
+ to :func:`_sa.create_engine`. A single :class:`_engine.
2841
+ Engine` will be
2842
+ passed to the :meth:`.CreateEnginePlugin.engine_created` method
2843
+ corresponding to this URL.
2844
+
2845
+ :param url: the :class:`_engine.URL` object. The plugin may inspect
2846
+ the :class:`_engine.URL` for arguments. Arguments used by the
2847
+ plugin should be removed, by returning an updated :class:`_engine.URL`
2848
+ from the :meth:`_engine.CreateEnginePlugin.update_url` method.
2849
+
2850
+ .. versionchanged:: 1.4
2851
+
2852
+ The :class:`_engine.URL` object is now immutable, so a
2853
+ :class:`_engine.CreateEnginePlugin` that needs to alter the
2854
+ :class:`_engine.URL` object should implement the
2855
+ :meth:`_engine.CreateEnginePlugin.update_url` method.
2856
+
2857
+ :param kwargs: The keyword arguments passed to
2858
+ :func:`_sa.create_engine`.
2859
+
2860
+ """
2861
+ self.url = url
2862
+
2863
+ def update_url(self, url: URL) -> URL:
2864
+ """Update the :class:`_engine.URL`.
2865
+
2866
+ A new :class:`_engine.URL` should be returned. This method is
2867
+ typically used to consume configuration arguments from the
2868
+ :class:`_engine.URL` which must be removed, as they will not be
2869
+ recognized by the dialect. The
2870
+ :meth:`_engine.URL.difference_update_query` method is available
2871
+ to remove these arguments. See the docstring at
2872
+ :class:`_engine.CreateEnginePlugin` for an example.
2873
+
2874
+
2875
+ .. versionadded:: 1.4
2876
+
2877
+ """
2878
+ raise NotImplementedError()
2879
+
2880
+ def handle_dialect_kwargs(
2881
+ self, dialect_cls: Type[Dialect], dialect_args: Dict[str, Any]
2882
+ ) -> None:
2883
+ """parse and modify dialect kwargs"""
2884
+
2885
+ def handle_pool_kwargs(
2886
+ self, pool_cls: Type[Pool], pool_args: Dict[str, Any]
2887
+ ) -> None:
2888
+ """parse and modify pool kwargs"""
2889
+
2890
+ def engine_created(self, engine: Engine) -> None:
2891
+ """Receive the :class:`_engine.Engine`
2892
+ object when it is fully constructed.
2893
+
2894
+ The plugin may make additional changes to the engine, such as
2895
+ registering engine or connection pool events.
2896
+
2897
+ """
2898
+
2899
+
2900
+ class ExecutionContext:
2901
+ """A messenger object for a Dialect that corresponds to a single
2902
+ execution.
2903
+
2904
+ """
2905
+
2906
+ engine: Engine
2907
+ """engine which the Connection is associated with"""
2908
+
2909
+ connection: Connection
2910
+ """Connection object which can be freely used by default value
2911
+ generators to execute SQL. This Connection should reference the
2912
+ same underlying connection/transactional resources of
2913
+ root_connection."""
2914
+
2915
+ root_connection: Connection
2916
+ """Connection object which is the source of this ExecutionContext."""
2917
+
2918
+ dialect: Dialect
2919
+ """dialect which created this ExecutionContext."""
2920
+
2921
+ cursor: DBAPICursor
2922
+ """DB-API cursor procured from the connection"""
2923
+
2924
+ compiled: Optional[Compiled]
2925
+ """if passed to constructor, sqlalchemy.engine.base.Compiled object
2926
+ being executed"""
2927
+
2928
+ statement: str
2929
+ """string version of the statement to be executed. Is either
2930
+ passed to the constructor, or must be created from the
2931
+ sql.Compiled object by the time pre_exec() has completed."""
2932
+
2933
+ invoked_statement: Optional[Executable]
2934
+ """The Executable statement object that was given in the first place.
2935
+
2936
+ This should be structurally equivalent to compiled.statement, but not
2937
+ necessarily the same object as in a caching scenario the compiled form
2938
+ will have been extracted from the cache.
2939
+
2940
+ """
2941
+
2942
+ parameters: _AnyMultiExecuteParams
2943
+ """bind parameters passed to the execute() or exec_driver_sql() methods.
2944
+
2945
+ These are always stored as a list of parameter entries. A single-element
2946
+ list corresponds to a ``cursor.execute()`` call and a multiple-element
2947
+ list corresponds to ``cursor.executemany()``, except in the case
2948
+ of :attr:`.ExecuteStyle.INSERTMANYVALUES` which will use
2949
+ ``cursor.execute()`` one or more times.
2950
+
2951
+ """
2952
+
2953
+ no_parameters: bool
2954
+ """True if the execution style does not use parameters"""
2955
+
2956
+ isinsert: bool
2957
+ """True if the statement is an INSERT."""
2958
+
2959
+ isupdate: bool
2960
+ """True if the statement is an UPDATE."""
2961
+
2962
+ execute_style: ExecuteStyle
2963
+ """the style of DBAPI cursor method that will be used to execute
2964
+ a statement.
2965
+
2966
+ .. versionadded:: 2.0
2967
+
2968
+ """
2969
+
2970
+ executemany: bool
2971
+ """True if the context has a list of more than one parameter set.
2972
+
2973
+ Historically this attribute links to whether ``cursor.execute()`` or
2974
+ ``cursor.executemany()`` will be used. It also can now mean that
2975
+ "insertmanyvalues" may be used which indicates one or more
2976
+ ``cursor.execute()`` calls.
2977
+
2978
+ """
2979
+
2980
+ prefetch_cols: util.generic_fn_descriptor[Optional[Sequence[Column[Any]]]]
2981
+ """a list of Column objects for which a client-side default
2982
+ was fired off. Applies to inserts and updates."""
2983
+
2984
+ postfetch_cols: util.generic_fn_descriptor[Optional[Sequence[Column[Any]]]]
2985
+ """a list of Column objects for which a server-side default or
2986
+ inline SQL expression value was fired off. Applies to inserts
2987
+ and updates."""
2988
+
2989
+ execution_options: _ExecuteOptions
2990
+ """Execution options associated with the current statement execution"""
2991
+
2992
+ @classmethod
2993
+ def _init_ddl(
2994
+ cls,
2995
+ dialect: Dialect,
2996
+ connection: Connection,
2997
+ dbapi_connection: PoolProxiedConnection,
2998
+ execution_options: _ExecuteOptions,
2999
+ compiled_ddl: DDLCompiler,
3000
+ ) -> ExecutionContext:
3001
+ raise NotImplementedError()
3002
+
3003
+ @classmethod
3004
+ def _init_compiled(
3005
+ cls,
3006
+ dialect: Dialect,
3007
+ connection: Connection,
3008
+ dbapi_connection: PoolProxiedConnection,
3009
+ execution_options: _ExecuteOptions,
3010
+ compiled: SQLCompiler,
3011
+ parameters: _CoreMultiExecuteParams,
3012
+ invoked_statement: Executable,
3013
+ extracted_parameters: Optional[Sequence[BindParameter[Any]]],
3014
+ cache_hit: CacheStats = CacheStats.CACHING_DISABLED,
3015
+ ) -> ExecutionContext:
3016
+ raise NotImplementedError()
3017
+
3018
+ @classmethod
3019
+ def _init_statement(
3020
+ cls,
3021
+ dialect: Dialect,
3022
+ connection: Connection,
3023
+ dbapi_connection: PoolProxiedConnection,
3024
+ execution_options: _ExecuteOptions,
3025
+ statement: str,
3026
+ parameters: _DBAPIMultiExecuteParams,
3027
+ ) -> ExecutionContext:
3028
+ raise NotImplementedError()
3029
+
3030
+ @classmethod
3031
+ def _init_default(
3032
+ cls,
3033
+ dialect: Dialect,
3034
+ connection: Connection,
3035
+ dbapi_connection: PoolProxiedConnection,
3036
+ execution_options: _ExecuteOptions,
3037
+ ) -> ExecutionContext:
3038
+ raise NotImplementedError()
3039
+
3040
+ def _exec_default(
3041
+ self,
3042
+ column: Optional[Column[Any]],
3043
+ default: DefaultGenerator,
3044
+ type_: Optional[TypeEngine[Any]],
3045
+ ) -> Any:
3046
+ raise NotImplementedError()
3047
+
3048
+ def _prepare_set_input_sizes(
3049
+ self,
3050
+ ) -> Optional[List[Tuple[str, Any, TypeEngine[Any]]]]:
3051
+ raise NotImplementedError()
3052
+
3053
+ def _get_cache_stats(self) -> str:
3054
+ raise NotImplementedError()
3055
+
3056
+ def _setup_result_proxy(self) -> CursorResult[Any]:
3057
+ raise NotImplementedError()
3058
+
3059
+ def fire_sequence(self, seq: Sequence_SchemaItem, type_: Integer) -> int:
3060
+ """given a :class:`.Sequence`, invoke it and return the next int
3061
+ value"""
3062
+ raise NotImplementedError()
3063
+
3064
+ def create_cursor(self) -> DBAPICursor:
3065
+ """Return a new cursor generated from this ExecutionContext's
3066
+ connection.
3067
+
3068
+ Some dialects may wish to change the behavior of
3069
+ connection.cursor(), such as postgresql which may return a PG
3070
+ "server side" cursor.
3071
+ """
3072
+
3073
+ raise NotImplementedError()
3074
+
3075
+ def pre_exec(self) -> None:
3076
+ """Called before an execution of a compiled statement.
3077
+
3078
+ If a compiled statement was passed to this ExecutionContext,
3079
+ the `statement` and `parameters` datamembers must be
3080
+ initialized after this statement is complete.
3081
+ """
3082
+
3083
+ raise NotImplementedError()
3084
+
3085
+ def get_out_parameter_values(
3086
+ self, out_param_names: Sequence[str]
3087
+ ) -> Sequence[Any]:
3088
+ """Return a sequence of OUT parameter values from a cursor.
3089
+
3090
+ For dialects that support OUT parameters, this method will be called
3091
+ when there is a :class:`.SQLCompiler` object which has the
3092
+ :attr:`.SQLCompiler.has_out_parameters` flag set. This flag in turn
3093
+ will be set to True if the statement itself has :class:`.BindParameter`
3094
+ objects that have the ``.isoutparam`` flag set which are consumed by
3095
+ the :meth:`.SQLCompiler.visit_bindparam` method. If the dialect
3096
+ compiler produces :class:`.BindParameter` objects with ``.isoutparam``
3097
+ set which are not handled by :meth:`.SQLCompiler.visit_bindparam`, it
3098
+ should set this flag explicitly.
3099
+
3100
+ The list of names that were rendered for each bound parameter
3101
+ is passed to the method. The method should then return a sequence of
3102
+ values corresponding to the list of parameter objects. Unlike in
3103
+ previous SQLAlchemy versions, the values can be the **raw values** from
3104
+ the DBAPI; the execution context will apply the appropriate type
3105
+ handler based on what's present in self.compiled.binds and update the
3106
+ values. The processed dictionary will then be made available via the
3107
+ ``.out_parameters`` collection on the result object. Note that
3108
+ SQLAlchemy 1.4 has multiple kinds of result object as part of the 2.0
3109
+ transition.
3110
+
3111
+ .. versionadded:: 1.4 - added
3112
+ :meth:`.ExecutionContext.get_out_parameter_values`, which is invoked
3113
+ automatically by the :class:`.DefaultExecutionContext` when there
3114
+ are :class:`.BindParameter` objects with the ``.isoutparam`` flag
3115
+ set. This replaces the practice of setting out parameters within
3116
+ the now-removed ``get_result_proxy()`` method.
3117
+
3118
+ """
3119
+ raise NotImplementedError()
3120
+
3121
+ def post_exec(self) -> None:
3122
+ """Called after the execution of a compiled statement.
3123
+
3124
+ If a compiled statement was passed to this ExecutionContext,
3125
+ the `last_insert_ids`, `last_inserted_params`, etc.
3126
+ datamembers should be available after this method completes.
3127
+ """
3128
+
3129
+ raise NotImplementedError()
3130
+
3131
+ def handle_dbapi_exception(self, e: BaseException) -> None:
3132
+ """Receive a DBAPI exception which occurred upon execute, result
3133
+ fetch, etc."""
3134
+
3135
+ raise NotImplementedError()
3136
+
3137
+ def lastrow_has_defaults(self) -> bool:
3138
+ """Return True if the last INSERT or UPDATE row contained
3139
+ inlined or database-side defaults.
3140
+ """
3141
+
3142
+ raise NotImplementedError()
3143
+
3144
+ def get_rowcount(self) -> Optional[int]:
3145
+ """Return the DBAPI ``cursor.rowcount`` value, or in some
3146
+ cases an interpreted value.
3147
+
3148
+ See :attr:`_engine.CursorResult.rowcount` for details on this.
3149
+
3150
+ """
3151
+
3152
+ raise NotImplementedError()
3153
+
3154
+ def fetchall_for_returning(self, cursor: DBAPICursor) -> Sequence[Any]:
3155
+ """For a RETURNING result, deliver cursor.fetchall() from the
3156
+ DBAPI cursor.
3157
+
3158
+ This is a dialect-specific hook for dialects that have special
3159
+ considerations when calling upon the rows delivered for a
3160
+ "RETURNING" statement. Default implementation is
3161
+ ``cursor.fetchall()``.
3162
+
3163
+ This hook is currently used only by the :term:`insertmanyvalues`
3164
+ feature. Dialects that don't set ``use_insertmanyvalues=True``
3165
+ don't need to consider this hook.
3166
+
3167
+ .. versionadded:: 2.0.10
3168
+
3169
+ """
3170
+ raise NotImplementedError()
3171
+
3172
+
3173
+ class ConnectionEventsTarget(EventTarget):
3174
+ """An object which can accept events from :class:`.ConnectionEvents`.
3175
+
3176
+ Includes :class:`_engine.Connection` and :class:`_engine.Engine`.
3177
+
3178
+ .. versionadded:: 2.0
3179
+
3180
+ """
3181
+
3182
+ dispatch: dispatcher[ConnectionEventsTarget]
3183
+
3184
+
3185
+ Connectable = ConnectionEventsTarget
3186
+
3187
+
3188
+ class ExceptionContext:
3189
+ """Encapsulate information about an error condition in progress.
3190
+
3191
+ This object exists solely to be passed to the
3192
+ :meth:`_events.DialectEvents.handle_error` event,
3193
+ supporting an interface that
3194
+ can be extended without backwards-incompatibility.
3195
+
3196
+
3197
+ """
3198
+
3199
+ __slots__ = ()
3200
+
3201
+ dialect: Dialect
3202
+ """The :class:`_engine.Dialect` in use.
3203
+
3204
+ This member is present for all invocations of the event hook.
3205
+
3206
+ .. versionadded:: 2.0
3207
+
3208
+ """
3209
+
3210
+ connection: Optional[Connection]
3211
+ """The :class:`_engine.Connection` in use during the exception.
3212
+
3213
+ This member is present, except in the case of a failure when
3214
+ first connecting.
3215
+
3216
+ .. seealso::
3217
+
3218
+ :attr:`.ExceptionContext.engine`
3219
+
3220
+
3221
+ """
3222
+
3223
+ engine: Optional[Engine]
3224
+ """The :class:`_engine.Engine` in use during the exception.
3225
+
3226
+ This member is present in all cases except for when handling an error
3227
+ within the connection pool "pre-ping" process.
3228
+
3229
+ """
3230
+
3231
+ cursor: Optional[DBAPICursor]
3232
+ """The DBAPI cursor object.
3233
+
3234
+ May be None.
3235
+
3236
+ """
3237
+
3238
+ statement: Optional[str]
3239
+ """String SQL statement that was emitted directly to the DBAPI.
3240
+
3241
+ May be None.
3242
+
3243
+ """
3244
+
3245
+ parameters: Optional[_DBAPIAnyExecuteParams]
3246
+ """Parameter collection that was emitted directly to the DBAPI.
3247
+
3248
+ May be None.
3249
+
3250
+ """
3251
+
3252
+ original_exception: BaseException
3253
+ """The exception object which was caught.
3254
+
3255
+ This member is always present.
3256
+
3257
+ """
3258
+
3259
+ sqlalchemy_exception: Optional[StatementError]
3260
+ """The :class:`sqlalchemy.exc.StatementError` which wraps the original,
3261
+ and will be raised if exception handling is not circumvented by the event.
3262
+
3263
+ May be None, as not all exception types are wrapped by SQLAlchemy.
3264
+ For DBAPI-level exceptions that subclass the dbapi's Error class, this
3265
+ field will always be present.
3266
+
3267
+ """
3268
+
3269
+ chained_exception: Optional[BaseException]
3270
+ """The exception that was returned by the previous handler in the
3271
+ exception chain, if any.
3272
+
3273
+ If present, this exception will be the one ultimately raised by
3274
+ SQLAlchemy unless a subsequent handler replaces it.
3275
+
3276
+ May be None.
3277
+
3278
+ """
3279
+
3280
+ execution_context: Optional[ExecutionContext]
3281
+ """The :class:`.ExecutionContext` corresponding to the execution
3282
+ operation in progress.
3283
+
3284
+ This is present for statement execution operations, but not for
3285
+ operations such as transaction begin/end. It also is not present when
3286
+ the exception was raised before the :class:`.ExecutionContext`
3287
+ could be constructed.
3288
+
3289
+ Note that the :attr:`.ExceptionContext.statement` and
3290
+ :attr:`.ExceptionContext.parameters` members may represent a
3291
+ different value than that of the :class:`.ExecutionContext`,
3292
+ potentially in the case where a
3293
+ :meth:`_events.ConnectionEvents.before_cursor_execute` event or similar
3294
+ modified the statement/parameters to be sent.
3295
+
3296
+ May be None.
3297
+
3298
+ """
3299
+
3300
+ is_disconnect: bool
3301
+ """Represent whether the exception as occurred represents a "disconnect"
3302
+ condition.
3303
+
3304
+ This flag will always be True or False within the scope of the
3305
+ :meth:`_events.DialectEvents.handle_error` handler.
3306
+
3307
+ SQLAlchemy will defer to this flag in order to determine whether or not
3308
+ the connection should be invalidated subsequently. That is, by
3309
+ assigning to this flag, a "disconnect" event which then results in
3310
+ a connection and pool invalidation can be invoked or prevented by
3311
+ changing this flag.
3312
+
3313
+
3314
+ .. note:: The pool "pre_ping" handler enabled using the
3315
+ :paramref:`_sa.create_engine.pool_pre_ping` parameter does **not**
3316
+ consult this event before deciding if the "ping" returned false,
3317
+ as opposed to receiving an unhandled error. For this use case, the
3318
+ :ref:`legacy recipe based on engine_connect() may be used
3319
+ <pool_disconnects_pessimistic_custom>`. A future API allow more
3320
+ comprehensive customization of the "disconnect" detection mechanism
3321
+ across all functions.
3322
+
3323
+ """
3324
+
3325
+ invalidate_pool_on_disconnect: bool
3326
+ """Represent whether all connections in the pool should be invalidated
3327
+ when a "disconnect" condition is in effect.
3328
+
3329
+ Setting this flag to False within the scope of the
3330
+ :meth:`_events.DialectEvents.handle_error`
3331
+ event will have the effect such
3332
+ that the full collection of connections in the pool will not be
3333
+ invalidated during a disconnect; only the current connection that is the
3334
+ subject of the error will actually be invalidated.
3335
+
3336
+ The purpose of this flag is for custom disconnect-handling schemes where
3337
+ the invalidation of other connections in the pool is to be performed
3338
+ based on other conditions, or even on a per-connection basis.
3339
+
3340
+ """
3341
+
3342
+ is_pre_ping: bool
3343
+ """Indicates if this error is occurring within the "pre-ping" step
3344
+ performed when :paramref:`_sa.create_engine.pool_pre_ping` is set to
3345
+ ``True``. In this mode, the :attr:`.ExceptionContext.engine` attribute
3346
+ will be ``None``. The dialect in use is accessible via the
3347
+ :attr:`.ExceptionContext.dialect` attribute.
3348
+
3349
+ .. versionadded:: 2.0.5
3350
+
3351
+ """
3352
+
3353
+
3354
+ class AdaptedConnection:
3355
+ """Interface of an adapted connection object to support the DBAPI protocol.
3356
+
3357
+ Used by asyncio dialects to provide a sync-style pep-249 facade on top
3358
+ of the asyncio connection/cursor API provided by the driver.
3359
+
3360
+ .. versionadded:: 1.4.24
3361
+
3362
+ """
3363
+
3364
+ __slots__ = ("_connection",)
3365
+
3366
+ _connection: Any
3367
+
3368
+ @property
3369
+ def driver_connection(self) -> Any:
3370
+ """The connection object as returned by the driver after a connect."""
3371
+ return self._connection
3372
+
3373
+ def run_async(self, fn: Callable[[Any], Awaitable[_T]]) -> _T:
3374
+ """Run the awaitable returned by the given function, which is passed
3375
+ the raw asyncio driver connection.
3376
+
3377
+ This is used to invoke awaitable-only methods on the driver connection
3378
+ within the context of a "synchronous" method, like a connection
3379
+ pool event handler.
3380
+
3381
+ E.g.::
3382
+
3383
+ engine = create_async_engine(...)
3384
+
3385
+ @event.listens_for(engine.sync_engine, "connect")
3386
+ def register_custom_types(dbapi_connection, ...):
3387
+ dbapi_connection.run_async(
3388
+ lambda connection: connection.set_type_codec(
3389
+ 'MyCustomType', encoder, decoder, ...
3390
+ )
3391
+ )
3392
+
3393
+ .. versionadded:: 1.4.30
3394
+
3395
+ .. seealso::
3396
+
3397
+ :ref:`asyncio_events_run_async`
3398
+
3399
+ """
3400
+ return await_only(fn(self._connection))
3401
+
3402
+ def __repr__(self) -> str:
3403
+ return "<AdaptedConnection %s>" % self._connection