SQLAlchemy 2.0.36__cp313-cp313-win32.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-win32.pyd +0 -0
  13. sqlalchemy/cyextension/collections.pyx +409 -0
  14. sqlalchemy/cyextension/immutabledict.cp313-win32.pyd +0 -0
  15. sqlalchemy/cyextension/immutabledict.pxd +8 -0
  16. sqlalchemy/cyextension/immutabledict.pyx +133 -0
  17. sqlalchemy/cyextension/processors.cp313-win32.pyd +0 -0
  18. sqlalchemy/cyextension/processors.pyx +68 -0
  19. sqlalchemy/cyextension/resultproxy.cp313-win32.pyd +0 -0
  20. sqlalchemy/cyextension/resultproxy.pyx +102 -0
  21. sqlalchemy/cyextension/util.cp313-win32.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,635 @@
1
+ # sql/_selectable_constructors.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
+ from __future__ import annotations
9
+
10
+ from typing import Any
11
+ from typing import Optional
12
+ from typing import overload
13
+ from typing import Tuple
14
+ from typing import TYPE_CHECKING
15
+ from typing import TypeVar
16
+ from typing import Union
17
+
18
+ from . import coercions
19
+ from . import roles
20
+ from ._typing import _ColumnsClauseArgument
21
+ from ._typing import _no_kw
22
+ from .elements import ColumnClause
23
+ from .selectable import Alias
24
+ from .selectable import CompoundSelect
25
+ from .selectable import Exists
26
+ from .selectable import FromClause
27
+ from .selectable import Join
28
+ from .selectable import Lateral
29
+ from .selectable import LateralFromClause
30
+ from .selectable import NamedFromClause
31
+ from .selectable import Select
32
+ from .selectable import TableClause
33
+ from .selectable import TableSample
34
+ from .selectable import Values
35
+
36
+ if TYPE_CHECKING:
37
+ from ._typing import _FromClauseArgument
38
+ from ._typing import _OnClauseArgument
39
+ from ._typing import _SelectStatementForCompoundArgument
40
+ from ._typing import _T0
41
+ from ._typing import _T1
42
+ from ._typing import _T2
43
+ from ._typing import _T3
44
+ from ._typing import _T4
45
+ from ._typing import _T5
46
+ from ._typing import _T6
47
+ from ._typing import _T7
48
+ from ._typing import _T8
49
+ from ._typing import _T9
50
+ from ._typing import _TypedColumnClauseArgument as _TCCA
51
+ from .functions import Function
52
+ from .selectable import CTE
53
+ from .selectable import HasCTE
54
+ from .selectable import ScalarSelect
55
+ from .selectable import SelectBase
56
+
57
+
58
+ _T = TypeVar("_T", bound=Any)
59
+
60
+
61
+ def alias(
62
+ selectable: FromClause, name: Optional[str] = None, flat: bool = False
63
+ ) -> NamedFromClause:
64
+ """Return a named alias of the given :class:`.FromClause`.
65
+
66
+ For :class:`.Table` and :class:`.Join` objects, the return type is the
67
+ :class:`_expression.Alias` object. Other kinds of :class:`.NamedFromClause`
68
+ objects may be returned for other kinds of :class:`.FromClause` objects.
69
+
70
+ The named alias represents any :class:`_expression.FromClause` with an
71
+ alternate name assigned within SQL, typically using the ``AS`` clause when
72
+ generated, e.g. ``SELECT * FROM table AS aliasname``.
73
+
74
+ Equivalent functionality is available via the
75
+ :meth:`_expression.FromClause.alias`
76
+ method available on all :class:`_expression.FromClause` objects.
77
+
78
+ :param selectable: any :class:`_expression.FromClause` subclass,
79
+ such as a table, select statement, etc.
80
+
81
+ :param name: string name to be assigned as the alias.
82
+ If ``None``, a name will be deterministically generated at compile
83
+ time. Deterministic means the name is guaranteed to be unique against
84
+ other constructs used in the same statement, and will also be the same
85
+ name for each successive compilation of the same statement object.
86
+
87
+ :param flat: Will be passed through to if the given selectable
88
+ is an instance of :class:`_expression.Join` - see
89
+ :meth:`_expression.Join.alias` for details.
90
+
91
+ """
92
+ return Alias._factory(selectable, name=name, flat=flat)
93
+
94
+
95
+ def cte(
96
+ selectable: HasCTE, name: Optional[str] = None, recursive: bool = False
97
+ ) -> CTE:
98
+ r"""Return a new :class:`_expression.CTE`,
99
+ or Common Table Expression instance.
100
+
101
+ Please see :meth:`_expression.HasCTE.cte` for detail on CTE usage.
102
+
103
+ """
104
+ return coercions.expect(roles.HasCTERole, selectable).cte(
105
+ name=name, recursive=recursive
106
+ )
107
+
108
+
109
+ def except_(
110
+ *selects: _SelectStatementForCompoundArgument,
111
+ ) -> CompoundSelect:
112
+ r"""Return an ``EXCEPT`` of multiple selectables.
113
+
114
+ The returned object is an instance of
115
+ :class:`_expression.CompoundSelect`.
116
+
117
+ :param \*selects:
118
+ a list of :class:`_expression.Select` instances.
119
+
120
+ """
121
+ return CompoundSelect._create_except(*selects)
122
+
123
+
124
+ def except_all(
125
+ *selects: _SelectStatementForCompoundArgument,
126
+ ) -> CompoundSelect:
127
+ r"""Return an ``EXCEPT ALL`` of multiple selectables.
128
+
129
+ The returned object is an instance of
130
+ :class:`_expression.CompoundSelect`.
131
+
132
+ :param \*selects:
133
+ a list of :class:`_expression.Select` instances.
134
+
135
+ """
136
+ return CompoundSelect._create_except_all(*selects)
137
+
138
+
139
+ def exists(
140
+ __argument: Optional[
141
+ Union[_ColumnsClauseArgument[Any], SelectBase, ScalarSelect[Any]]
142
+ ] = None,
143
+ ) -> Exists:
144
+ """Construct a new :class:`_expression.Exists` construct.
145
+
146
+ The :func:`_sql.exists` can be invoked by itself to produce an
147
+ :class:`_sql.Exists` construct, which will accept simple WHERE
148
+ criteria::
149
+
150
+ exists_criteria = exists().where(table1.c.col1 == table2.c.col2)
151
+
152
+ However, for greater flexibility in constructing the SELECT, an
153
+ existing :class:`_sql.Select` construct may be converted to an
154
+ :class:`_sql.Exists`, most conveniently by making use of the
155
+ :meth:`_sql.SelectBase.exists` method::
156
+
157
+ exists_criteria = (
158
+ select(table2.c.col2).
159
+ where(table1.c.col1 == table2.c.col2).
160
+ exists()
161
+ )
162
+
163
+ The EXISTS criteria is then used inside of an enclosing SELECT::
164
+
165
+ stmt = select(table1.c.col1).where(exists_criteria)
166
+
167
+ The above statement will then be of the form::
168
+
169
+ SELECT col1 FROM table1 WHERE EXISTS
170
+ (SELECT table2.col2 FROM table2 WHERE table2.col2 = table1.col1)
171
+
172
+ .. seealso::
173
+
174
+ :ref:`tutorial_exists` - in the :term:`2.0 style` tutorial.
175
+
176
+ :meth:`_sql.SelectBase.exists` - method to transform a ``SELECT`` to an
177
+ ``EXISTS`` clause.
178
+
179
+ """ # noqa: E501
180
+
181
+ return Exists(__argument)
182
+
183
+
184
+ def intersect(
185
+ *selects: _SelectStatementForCompoundArgument,
186
+ ) -> CompoundSelect:
187
+ r"""Return an ``INTERSECT`` of multiple selectables.
188
+
189
+ The returned object is an instance of
190
+ :class:`_expression.CompoundSelect`.
191
+
192
+ :param \*selects:
193
+ a list of :class:`_expression.Select` instances.
194
+
195
+ """
196
+ return CompoundSelect._create_intersect(*selects)
197
+
198
+
199
+ def intersect_all(
200
+ *selects: _SelectStatementForCompoundArgument,
201
+ ) -> CompoundSelect:
202
+ r"""Return an ``INTERSECT ALL`` of multiple selectables.
203
+
204
+ The returned object is an instance of
205
+ :class:`_expression.CompoundSelect`.
206
+
207
+ :param \*selects:
208
+ a list of :class:`_expression.Select` instances.
209
+
210
+
211
+ """
212
+ return CompoundSelect._create_intersect_all(*selects)
213
+
214
+
215
+ def join(
216
+ left: _FromClauseArgument,
217
+ right: _FromClauseArgument,
218
+ onclause: Optional[_OnClauseArgument] = None,
219
+ isouter: bool = False,
220
+ full: bool = False,
221
+ ) -> Join:
222
+ """Produce a :class:`_expression.Join` object, given two
223
+ :class:`_expression.FromClause`
224
+ expressions.
225
+
226
+ E.g.::
227
+
228
+ j = join(user_table, address_table,
229
+ user_table.c.id == address_table.c.user_id)
230
+ stmt = select(user_table).select_from(j)
231
+
232
+ would emit SQL along the lines of::
233
+
234
+ SELECT user.id, user.name FROM user
235
+ JOIN address ON user.id = address.user_id
236
+
237
+ Similar functionality is available given any
238
+ :class:`_expression.FromClause` object (e.g. such as a
239
+ :class:`_schema.Table`) using
240
+ the :meth:`_expression.FromClause.join` method.
241
+
242
+ :param left: The left side of the join.
243
+
244
+ :param right: the right side of the join; this is any
245
+ :class:`_expression.FromClause` object such as a
246
+ :class:`_schema.Table` object, and
247
+ may also be a selectable-compatible object such as an ORM-mapped
248
+ class.
249
+
250
+ :param onclause: a SQL expression representing the ON clause of the
251
+ join. If left at ``None``, :meth:`_expression.FromClause.join`
252
+ will attempt to
253
+ join the two tables based on a foreign key relationship.
254
+
255
+ :param isouter: if True, render a LEFT OUTER JOIN, instead of JOIN.
256
+
257
+ :param full: if True, render a FULL OUTER JOIN, instead of JOIN.
258
+
259
+ .. seealso::
260
+
261
+ :meth:`_expression.FromClause.join` - method form,
262
+ based on a given left side.
263
+
264
+ :class:`_expression.Join` - the type of object produced.
265
+
266
+ """
267
+
268
+ return Join(left, right, onclause, isouter, full)
269
+
270
+
271
+ def lateral(
272
+ selectable: Union[SelectBase, _FromClauseArgument],
273
+ name: Optional[str] = None,
274
+ ) -> LateralFromClause:
275
+ """Return a :class:`_expression.Lateral` object.
276
+
277
+ :class:`_expression.Lateral` is an :class:`_expression.Alias`
278
+ subclass that represents
279
+ a subquery with the LATERAL keyword applied to it.
280
+
281
+ The special behavior of a LATERAL subquery is that it appears in the
282
+ FROM clause of an enclosing SELECT, but may correlate to other
283
+ FROM clauses of that SELECT. It is a special case of subquery
284
+ only supported by a small number of backends, currently more recent
285
+ PostgreSQL versions.
286
+
287
+ .. seealso::
288
+
289
+ :ref:`tutorial_lateral_correlation` - overview of usage.
290
+
291
+ """
292
+ return Lateral._factory(selectable, name=name)
293
+
294
+
295
+ def outerjoin(
296
+ left: _FromClauseArgument,
297
+ right: _FromClauseArgument,
298
+ onclause: Optional[_OnClauseArgument] = None,
299
+ full: bool = False,
300
+ ) -> Join:
301
+ """Return an ``OUTER JOIN`` clause element.
302
+
303
+ The returned object is an instance of :class:`_expression.Join`.
304
+
305
+ Similar functionality is also available via the
306
+ :meth:`_expression.FromClause.outerjoin` method on any
307
+ :class:`_expression.FromClause`.
308
+
309
+ :param left: The left side of the join.
310
+
311
+ :param right: The right side of the join.
312
+
313
+ :param onclause: Optional criterion for the ``ON`` clause, is
314
+ derived from foreign key relationships established between
315
+ left and right otherwise.
316
+
317
+ To chain joins together, use the :meth:`_expression.FromClause.join`
318
+ or
319
+ :meth:`_expression.FromClause.outerjoin` methods on the resulting
320
+ :class:`_expression.Join` object.
321
+
322
+ """
323
+ return Join(left, right, onclause, isouter=True, full=full)
324
+
325
+
326
+ # START OVERLOADED FUNCTIONS select Select 1-10
327
+
328
+ # code within this block is **programmatically,
329
+ # statically generated** by tools/generate_tuple_map_overloads.py
330
+
331
+
332
+ @overload
333
+ def select(__ent0: _TCCA[_T0]) -> Select[Tuple[_T0]]: ...
334
+
335
+
336
+ @overload
337
+ def select(
338
+ __ent0: _TCCA[_T0], __ent1: _TCCA[_T1]
339
+ ) -> Select[Tuple[_T0, _T1]]: ...
340
+
341
+
342
+ @overload
343
+ def select(
344
+ __ent0: _TCCA[_T0], __ent1: _TCCA[_T1], __ent2: _TCCA[_T2]
345
+ ) -> Select[Tuple[_T0, _T1, _T2]]: ...
346
+
347
+
348
+ @overload
349
+ def select(
350
+ __ent0: _TCCA[_T0],
351
+ __ent1: _TCCA[_T1],
352
+ __ent2: _TCCA[_T2],
353
+ __ent3: _TCCA[_T3],
354
+ ) -> Select[Tuple[_T0, _T1, _T2, _T3]]: ...
355
+
356
+
357
+ @overload
358
+ def select(
359
+ __ent0: _TCCA[_T0],
360
+ __ent1: _TCCA[_T1],
361
+ __ent2: _TCCA[_T2],
362
+ __ent3: _TCCA[_T3],
363
+ __ent4: _TCCA[_T4],
364
+ ) -> Select[Tuple[_T0, _T1, _T2, _T3, _T4]]: ...
365
+
366
+
367
+ @overload
368
+ def select(
369
+ __ent0: _TCCA[_T0],
370
+ __ent1: _TCCA[_T1],
371
+ __ent2: _TCCA[_T2],
372
+ __ent3: _TCCA[_T3],
373
+ __ent4: _TCCA[_T4],
374
+ __ent5: _TCCA[_T5],
375
+ ) -> Select[Tuple[_T0, _T1, _T2, _T3, _T4, _T5]]: ...
376
+
377
+
378
+ @overload
379
+ def select(
380
+ __ent0: _TCCA[_T0],
381
+ __ent1: _TCCA[_T1],
382
+ __ent2: _TCCA[_T2],
383
+ __ent3: _TCCA[_T3],
384
+ __ent4: _TCCA[_T4],
385
+ __ent5: _TCCA[_T5],
386
+ __ent6: _TCCA[_T6],
387
+ ) -> Select[Tuple[_T0, _T1, _T2, _T3, _T4, _T5, _T6]]: ...
388
+
389
+
390
+ @overload
391
+ def select(
392
+ __ent0: _TCCA[_T0],
393
+ __ent1: _TCCA[_T1],
394
+ __ent2: _TCCA[_T2],
395
+ __ent3: _TCCA[_T3],
396
+ __ent4: _TCCA[_T4],
397
+ __ent5: _TCCA[_T5],
398
+ __ent6: _TCCA[_T6],
399
+ __ent7: _TCCA[_T7],
400
+ ) -> Select[Tuple[_T0, _T1, _T2, _T3, _T4, _T5, _T6, _T7]]: ...
401
+
402
+
403
+ @overload
404
+ def select(
405
+ __ent0: _TCCA[_T0],
406
+ __ent1: _TCCA[_T1],
407
+ __ent2: _TCCA[_T2],
408
+ __ent3: _TCCA[_T3],
409
+ __ent4: _TCCA[_T4],
410
+ __ent5: _TCCA[_T5],
411
+ __ent6: _TCCA[_T6],
412
+ __ent7: _TCCA[_T7],
413
+ __ent8: _TCCA[_T8],
414
+ ) -> Select[Tuple[_T0, _T1, _T2, _T3, _T4, _T5, _T6, _T7, _T8]]: ...
415
+
416
+
417
+ @overload
418
+ def select(
419
+ __ent0: _TCCA[_T0],
420
+ __ent1: _TCCA[_T1],
421
+ __ent2: _TCCA[_T2],
422
+ __ent3: _TCCA[_T3],
423
+ __ent4: _TCCA[_T4],
424
+ __ent5: _TCCA[_T5],
425
+ __ent6: _TCCA[_T6],
426
+ __ent7: _TCCA[_T7],
427
+ __ent8: _TCCA[_T8],
428
+ __ent9: _TCCA[_T9],
429
+ ) -> Select[Tuple[_T0, _T1, _T2, _T3, _T4, _T5, _T6, _T7, _T8, _T9]]: ...
430
+
431
+
432
+ # END OVERLOADED FUNCTIONS select
433
+
434
+
435
+ @overload
436
+ def select(
437
+ *entities: _ColumnsClauseArgument[Any], **__kw: Any
438
+ ) -> Select[Any]: ...
439
+
440
+
441
+ def select(*entities: _ColumnsClauseArgument[Any], **__kw: Any) -> Select[Any]:
442
+ r"""Construct a new :class:`_expression.Select`.
443
+
444
+
445
+ .. versionadded:: 1.4 - The :func:`_sql.select` function now accepts
446
+ column arguments positionally. The top-level :func:`_sql.select`
447
+ function will automatically use the 1.x or 2.x style API based on
448
+ the incoming arguments; using :func:`_sql.select` from the
449
+ ``sqlalchemy.future`` module will enforce that only the 2.x style
450
+ constructor is used.
451
+
452
+ Similar functionality is also available via the
453
+ :meth:`_expression.FromClause.select` method on any
454
+ :class:`_expression.FromClause`.
455
+
456
+ .. seealso::
457
+
458
+ :ref:`tutorial_selecting_data` - in the :ref:`unified_tutorial`
459
+
460
+ :param \*entities:
461
+ Entities to SELECT from. For Core usage, this is typically a series
462
+ of :class:`_expression.ColumnElement` and / or
463
+ :class:`_expression.FromClause`
464
+ objects which will form the columns clause of the resulting
465
+ statement. For those objects that are instances of
466
+ :class:`_expression.FromClause` (typically :class:`_schema.Table`
467
+ or :class:`_expression.Alias`
468
+ objects), the :attr:`_expression.FromClause.c`
469
+ collection is extracted
470
+ to form a collection of :class:`_expression.ColumnElement` objects.
471
+
472
+ This parameter will also accept :class:`_expression.TextClause`
473
+ constructs as
474
+ given, as well as ORM-mapped classes.
475
+
476
+ """
477
+ # the keyword args are a necessary element in order for the typing
478
+ # to work out w/ the varargs vs. having named "keyword" arguments that
479
+ # aren't always present.
480
+ if __kw:
481
+ raise _no_kw()
482
+ return Select(*entities)
483
+
484
+
485
+ def table(name: str, *columns: ColumnClause[Any], **kw: Any) -> TableClause:
486
+ """Produce a new :class:`_expression.TableClause`.
487
+
488
+ The object returned is an instance of
489
+ :class:`_expression.TableClause`, which
490
+ represents the "syntactical" portion of the schema-level
491
+ :class:`_schema.Table` object.
492
+ It may be used to construct lightweight table constructs.
493
+
494
+ :param name: Name of the table.
495
+
496
+ :param columns: A collection of :func:`_expression.column` constructs.
497
+
498
+ :param schema: The schema name for this table.
499
+
500
+ .. versionadded:: 1.3.18 :func:`_expression.table` can now
501
+ accept a ``schema`` argument.
502
+ """
503
+
504
+ return TableClause(name, *columns, **kw)
505
+
506
+
507
+ def tablesample(
508
+ selectable: _FromClauseArgument,
509
+ sampling: Union[float, Function[Any]],
510
+ name: Optional[str] = None,
511
+ seed: Optional[roles.ExpressionElementRole[Any]] = None,
512
+ ) -> TableSample:
513
+ """Return a :class:`_expression.TableSample` object.
514
+
515
+ :class:`_expression.TableSample` is an :class:`_expression.Alias`
516
+ subclass that represents
517
+ a table with the TABLESAMPLE clause applied to it.
518
+ :func:`_expression.tablesample`
519
+ is also available from the :class:`_expression.FromClause`
520
+ class via the
521
+ :meth:`_expression.FromClause.tablesample` method.
522
+
523
+ The TABLESAMPLE clause allows selecting a randomly selected approximate
524
+ percentage of rows from a table. It supports multiple sampling methods,
525
+ most commonly BERNOULLI and SYSTEM.
526
+
527
+ e.g.::
528
+
529
+ from sqlalchemy import func
530
+
531
+ selectable = people.tablesample(
532
+ func.bernoulli(1),
533
+ name='alias',
534
+ seed=func.random())
535
+ stmt = select(selectable.c.people_id)
536
+
537
+ Assuming ``people`` with a column ``people_id``, the above
538
+ statement would render as::
539
+
540
+ SELECT alias.people_id FROM
541
+ people AS alias TABLESAMPLE bernoulli(:bernoulli_1)
542
+ REPEATABLE (random())
543
+
544
+ :param sampling: a ``float`` percentage between 0 and 100 or
545
+ :class:`_functions.Function`.
546
+
547
+ :param name: optional alias name
548
+
549
+ :param seed: any real-valued SQL expression. When specified, the
550
+ REPEATABLE sub-clause is also rendered.
551
+
552
+ """
553
+ return TableSample._factory(selectable, sampling, name=name, seed=seed)
554
+
555
+
556
+ def union(
557
+ *selects: _SelectStatementForCompoundArgument,
558
+ ) -> CompoundSelect:
559
+ r"""Return a ``UNION`` of multiple selectables.
560
+
561
+ The returned object is an instance of
562
+ :class:`_expression.CompoundSelect`.
563
+
564
+ A similar :func:`union()` method is available on all
565
+ :class:`_expression.FromClause` subclasses.
566
+
567
+ :param \*selects:
568
+ a list of :class:`_expression.Select` instances.
569
+
570
+ :param \**kwargs:
571
+ available keyword arguments are the same as those of
572
+ :func:`select`.
573
+
574
+ """
575
+ return CompoundSelect._create_union(*selects)
576
+
577
+
578
+ def union_all(
579
+ *selects: _SelectStatementForCompoundArgument,
580
+ ) -> CompoundSelect:
581
+ r"""Return a ``UNION ALL`` of multiple selectables.
582
+
583
+ The returned object is an instance of
584
+ :class:`_expression.CompoundSelect`.
585
+
586
+ A similar :func:`union_all()` method is available on all
587
+ :class:`_expression.FromClause` subclasses.
588
+
589
+ :param \*selects:
590
+ a list of :class:`_expression.Select` instances.
591
+
592
+ """
593
+ return CompoundSelect._create_union_all(*selects)
594
+
595
+
596
+ def values(
597
+ *columns: ColumnClause[Any],
598
+ name: Optional[str] = None,
599
+ literal_binds: bool = False,
600
+ ) -> Values:
601
+ r"""Construct a :class:`_expression.Values` construct.
602
+
603
+ The column expressions and the actual data for
604
+ :class:`_expression.Values` are given in two separate steps. The
605
+ constructor receives the column expressions typically as
606
+ :func:`_expression.column` constructs,
607
+ and the data is then passed via the
608
+ :meth:`_expression.Values.data` method as a list,
609
+ which can be called multiple
610
+ times to add more data, e.g.::
611
+
612
+ from sqlalchemy import column
613
+ from sqlalchemy import values
614
+
615
+ value_expr = values(
616
+ column('id', Integer),
617
+ column('name', String),
618
+ name="my_values"
619
+ ).data(
620
+ [(1, 'name1'), (2, 'name2'), (3, 'name3')]
621
+ )
622
+
623
+ :param \*columns: column expressions, typically composed using
624
+ :func:`_expression.column` objects.
625
+
626
+ :param name: the name for this VALUES construct. If omitted, the
627
+ VALUES construct will be unnamed in a SQL expression. Different
628
+ backends may have different requirements here.
629
+
630
+ :param literal_binds: Defaults to False. Whether or not to render
631
+ the data values inline in the SQL output, rather than using bound
632
+ parameters.
633
+
634
+ """
635
+ return Values(*columns, literal_binds=literal_binds, name=name)