SQLAlchemy 2.1.0b2__cp313-cp313t-win_arm64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sqlalchemy/__init__.py +298 -0
- sqlalchemy/connectors/__init__.py +18 -0
- sqlalchemy/connectors/aioodbc.py +171 -0
- sqlalchemy/connectors/asyncio.py +476 -0
- sqlalchemy/connectors/pyodbc.py +250 -0
- sqlalchemy/dialects/__init__.py +62 -0
- sqlalchemy/dialects/_typing.py +30 -0
- sqlalchemy/dialects/mssql/__init__.py +89 -0
- sqlalchemy/dialects/mssql/aioodbc.py +63 -0
- sqlalchemy/dialects/mssql/base.py +4166 -0
- sqlalchemy/dialects/mssql/information_schema.py +285 -0
- sqlalchemy/dialects/mssql/json.py +140 -0
- sqlalchemy/dialects/mssql/mssqlpython.py +220 -0
- sqlalchemy/dialects/mssql/provision.py +196 -0
- sqlalchemy/dialects/mssql/pymssql.py +126 -0
- sqlalchemy/dialects/mssql/pyodbc.py +698 -0
- sqlalchemy/dialects/mysql/__init__.py +106 -0
- sqlalchemy/dialects/mysql/_mariadb_shim.py +312 -0
- sqlalchemy/dialects/mysql/aiomysql.py +226 -0
- sqlalchemy/dialects/mysql/asyncmy.py +214 -0
- sqlalchemy/dialects/mysql/base.py +3877 -0
- sqlalchemy/dialects/mysql/cymysql.py +106 -0
- sqlalchemy/dialects/mysql/dml.py +279 -0
- sqlalchemy/dialects/mysql/enumerated.py +277 -0
- sqlalchemy/dialects/mysql/expression.py +146 -0
- sqlalchemy/dialects/mysql/json.py +92 -0
- sqlalchemy/dialects/mysql/mariadb.py +67 -0
- sqlalchemy/dialects/mysql/mariadbconnector.py +330 -0
- sqlalchemy/dialects/mysql/mysqlconnector.py +296 -0
- sqlalchemy/dialects/mysql/mysqldb.py +312 -0
- sqlalchemy/dialects/mysql/provision.py +153 -0
- sqlalchemy/dialects/mysql/pymysql.py +157 -0
- sqlalchemy/dialects/mysql/pyodbc.py +156 -0
- sqlalchemy/dialects/mysql/reflection.py +724 -0
- sqlalchemy/dialects/mysql/reserved_words.py +570 -0
- sqlalchemy/dialects/mysql/types.py +845 -0
- sqlalchemy/dialects/oracle/__init__.py +85 -0
- sqlalchemy/dialects/oracle/base.py +3977 -0
- sqlalchemy/dialects/oracle/cx_oracle.py +1601 -0
- sqlalchemy/dialects/oracle/dictionary.py +507 -0
- sqlalchemy/dialects/oracle/json.py +158 -0
- sqlalchemy/dialects/oracle/oracledb.py +909 -0
- sqlalchemy/dialects/oracle/provision.py +288 -0
- sqlalchemy/dialects/oracle/types.py +367 -0
- sqlalchemy/dialects/oracle/vector.py +368 -0
- sqlalchemy/dialects/postgresql/__init__.py +171 -0
- sqlalchemy/dialects/postgresql/_psycopg_common.py +229 -0
- sqlalchemy/dialects/postgresql/array.py +534 -0
- sqlalchemy/dialects/postgresql/asyncpg.py +1323 -0
- sqlalchemy/dialects/postgresql/base.py +5789 -0
- sqlalchemy/dialects/postgresql/bitstring.py +327 -0
- sqlalchemy/dialects/postgresql/dml.py +360 -0
- sqlalchemy/dialects/postgresql/ext.py +593 -0
- sqlalchemy/dialects/postgresql/hstore.py +423 -0
- sqlalchemy/dialects/postgresql/json.py +408 -0
- sqlalchemy/dialects/postgresql/named_types.py +521 -0
- sqlalchemy/dialects/postgresql/operators.py +130 -0
- sqlalchemy/dialects/postgresql/pg8000.py +670 -0
- sqlalchemy/dialects/postgresql/pg_catalog.py +344 -0
- sqlalchemy/dialects/postgresql/provision.py +184 -0
- sqlalchemy/dialects/postgresql/psycopg.py +799 -0
- sqlalchemy/dialects/postgresql/psycopg2.py +860 -0
- sqlalchemy/dialects/postgresql/psycopg2cffi.py +61 -0
- sqlalchemy/dialects/postgresql/ranges.py +1002 -0
- sqlalchemy/dialects/postgresql/types.py +388 -0
- sqlalchemy/dialects/sqlite/__init__.py +57 -0
- sqlalchemy/dialects/sqlite/aiosqlite.py +321 -0
- sqlalchemy/dialects/sqlite/base.py +3063 -0
- sqlalchemy/dialects/sqlite/dml.py +279 -0
- sqlalchemy/dialects/sqlite/json.py +100 -0
- sqlalchemy/dialects/sqlite/provision.py +229 -0
- sqlalchemy/dialects/sqlite/pysqlcipher.py +161 -0
- sqlalchemy/dialects/sqlite/pysqlite.py +754 -0
- sqlalchemy/dialects/type_migration_guidelines.txt +145 -0
- sqlalchemy/engine/__init__.py +62 -0
- sqlalchemy/engine/_processors_cy.cp313t-win_arm64.pyd +0 -0
- sqlalchemy/engine/_processors_cy.py +92 -0
- sqlalchemy/engine/_result_cy.cp313t-win_arm64.pyd +0 -0
- sqlalchemy/engine/_result_cy.py +633 -0
- sqlalchemy/engine/_row_cy.cp313t-win_arm64.pyd +0 -0
- sqlalchemy/engine/_row_cy.py +232 -0
- sqlalchemy/engine/_util_cy.cp313t-win_arm64.pyd +0 -0
- sqlalchemy/engine/_util_cy.py +136 -0
- sqlalchemy/engine/base.py +3354 -0
- sqlalchemy/engine/characteristics.py +155 -0
- sqlalchemy/engine/create.py +877 -0
- sqlalchemy/engine/cursor.py +2421 -0
- sqlalchemy/engine/default.py +2402 -0
- sqlalchemy/engine/events.py +965 -0
- sqlalchemy/engine/interfaces.py +3495 -0
- sqlalchemy/engine/mock.py +134 -0
- sqlalchemy/engine/processors.py +82 -0
- sqlalchemy/engine/reflection.py +2100 -0
- sqlalchemy/engine/result.py +1966 -0
- sqlalchemy/engine/row.py +397 -0
- sqlalchemy/engine/strategies.py +16 -0
- sqlalchemy/engine/url.py +922 -0
- sqlalchemy/engine/util.py +156 -0
- sqlalchemy/event/__init__.py +26 -0
- sqlalchemy/event/api.py +220 -0
- sqlalchemy/event/attr.py +674 -0
- sqlalchemy/event/base.py +472 -0
- sqlalchemy/event/legacy.py +258 -0
- sqlalchemy/event/registry.py +390 -0
- sqlalchemy/events.py +17 -0
- sqlalchemy/exc.py +922 -0
- sqlalchemy/ext/__init__.py +11 -0
- sqlalchemy/ext/associationproxy.py +2072 -0
- sqlalchemy/ext/asyncio/__init__.py +29 -0
- sqlalchemy/ext/asyncio/base.py +281 -0
- sqlalchemy/ext/asyncio/engine.py +1487 -0
- sqlalchemy/ext/asyncio/exc.py +21 -0
- sqlalchemy/ext/asyncio/result.py +994 -0
- sqlalchemy/ext/asyncio/scoping.py +1679 -0
- sqlalchemy/ext/asyncio/session.py +2007 -0
- sqlalchemy/ext/automap.py +1701 -0
- sqlalchemy/ext/baked.py +559 -0
- sqlalchemy/ext/compiler.py +600 -0
- sqlalchemy/ext/declarative/__init__.py +65 -0
- sqlalchemy/ext/declarative/extensions.py +560 -0
- sqlalchemy/ext/horizontal_shard.py +481 -0
- sqlalchemy/ext/hybrid.py +1877 -0
- sqlalchemy/ext/indexable.py +364 -0
- sqlalchemy/ext/instrumentation.py +450 -0
- sqlalchemy/ext/mutable.py +1081 -0
- sqlalchemy/ext/orderinglist.py +439 -0
- sqlalchemy/ext/serializer.py +185 -0
- sqlalchemy/future/__init__.py +16 -0
- sqlalchemy/future/engine.py +15 -0
- sqlalchemy/inspection.py +174 -0
- sqlalchemy/log.py +283 -0
- sqlalchemy/orm/__init__.py +176 -0
- sqlalchemy/orm/_orm_constructors.py +2694 -0
- sqlalchemy/orm/_typing.py +179 -0
- sqlalchemy/orm/attributes.py +2868 -0
- sqlalchemy/orm/base.py +976 -0
- sqlalchemy/orm/bulk_persistence.py +2152 -0
- sqlalchemy/orm/clsregistry.py +582 -0
- sqlalchemy/orm/collections.py +1568 -0
- sqlalchemy/orm/context.py +3471 -0
- sqlalchemy/orm/decl_api.py +2280 -0
- sqlalchemy/orm/decl_base.py +2309 -0
- sqlalchemy/orm/dependency.py +1306 -0
- sqlalchemy/orm/descriptor_props.py +1183 -0
- sqlalchemy/orm/dynamic.py +307 -0
- sqlalchemy/orm/evaluator.py +379 -0
- sqlalchemy/orm/events.py +3386 -0
- sqlalchemy/orm/exc.py +237 -0
- sqlalchemy/orm/identity.py +302 -0
- sqlalchemy/orm/instrumentation.py +746 -0
- sqlalchemy/orm/interfaces.py +1589 -0
- sqlalchemy/orm/loading.py +1684 -0
- sqlalchemy/orm/mapped_collection.py +557 -0
- sqlalchemy/orm/mapper.py +4411 -0
- sqlalchemy/orm/path_registry.py +829 -0
- sqlalchemy/orm/persistence.py +1789 -0
- sqlalchemy/orm/properties.py +973 -0
- sqlalchemy/orm/query.py +3528 -0
- sqlalchemy/orm/relationships.py +3570 -0
- sqlalchemy/orm/scoping.py +2232 -0
- sqlalchemy/orm/session.py +5403 -0
- sqlalchemy/orm/state.py +1175 -0
- sqlalchemy/orm/state_changes.py +196 -0
- sqlalchemy/orm/strategies.py +3492 -0
- sqlalchemy/orm/strategy_options.py +2562 -0
- sqlalchemy/orm/sync.py +164 -0
- sqlalchemy/orm/unitofwork.py +798 -0
- sqlalchemy/orm/util.py +2438 -0
- sqlalchemy/orm/writeonly.py +694 -0
- sqlalchemy/pool/__init__.py +41 -0
- sqlalchemy/pool/base.py +1522 -0
- sqlalchemy/pool/events.py +375 -0
- sqlalchemy/pool/impl.py +582 -0
- sqlalchemy/py.typed +0 -0
- sqlalchemy/schema.py +74 -0
- sqlalchemy/sql/__init__.py +156 -0
- sqlalchemy/sql/_annotated_cols.py +397 -0
- sqlalchemy/sql/_dml_constructors.py +132 -0
- sqlalchemy/sql/_elements_constructors.py +2164 -0
- sqlalchemy/sql/_orm_types.py +20 -0
- sqlalchemy/sql/_selectable_constructors.py +840 -0
- sqlalchemy/sql/_typing.py +487 -0
- sqlalchemy/sql/_util_cy.cp313t-win_arm64.pyd +0 -0
- sqlalchemy/sql/_util_cy.py +127 -0
- sqlalchemy/sql/annotation.py +590 -0
- sqlalchemy/sql/base.py +2699 -0
- sqlalchemy/sql/cache_key.py +1066 -0
- sqlalchemy/sql/coercions.py +1373 -0
- sqlalchemy/sql/compiler.py +8327 -0
- sqlalchemy/sql/crud.py +1815 -0
- sqlalchemy/sql/ddl.py +1928 -0
- sqlalchemy/sql/default_comparator.py +654 -0
- sqlalchemy/sql/dml.py +1977 -0
- sqlalchemy/sql/elements.py +6033 -0
- sqlalchemy/sql/events.py +458 -0
- sqlalchemy/sql/expression.py +172 -0
- sqlalchemy/sql/functions.py +2305 -0
- sqlalchemy/sql/lambdas.py +1443 -0
- sqlalchemy/sql/naming.py +209 -0
- sqlalchemy/sql/operators.py +2897 -0
- sqlalchemy/sql/roles.py +332 -0
- sqlalchemy/sql/schema.py +6703 -0
- sqlalchemy/sql/selectable.py +7553 -0
- sqlalchemy/sql/sqltypes.py +4093 -0
- sqlalchemy/sql/traversals.py +1042 -0
- sqlalchemy/sql/type_api.py +2446 -0
- sqlalchemy/sql/util.py +1495 -0
- sqlalchemy/sql/visitors.py +1157 -0
- sqlalchemy/testing/__init__.py +96 -0
- sqlalchemy/testing/assertions.py +1007 -0
- sqlalchemy/testing/assertsql.py +519 -0
- sqlalchemy/testing/asyncio.py +128 -0
- sqlalchemy/testing/config.py +440 -0
- sqlalchemy/testing/engines.py +483 -0
- sqlalchemy/testing/entities.py +117 -0
- sqlalchemy/testing/exclusions.py +476 -0
- sqlalchemy/testing/fixtures/__init__.py +30 -0
- sqlalchemy/testing/fixtures/base.py +384 -0
- sqlalchemy/testing/fixtures/mypy.py +247 -0
- sqlalchemy/testing/fixtures/orm.py +227 -0
- sqlalchemy/testing/fixtures/sql.py +538 -0
- sqlalchemy/testing/pickleable.py +155 -0
- sqlalchemy/testing/plugin/__init__.py +6 -0
- sqlalchemy/testing/plugin/bootstrap.py +51 -0
- sqlalchemy/testing/plugin/plugin_base.py +828 -0
- sqlalchemy/testing/plugin/pytestplugin.py +892 -0
- sqlalchemy/testing/profiling.py +329 -0
- sqlalchemy/testing/provision.py +613 -0
- sqlalchemy/testing/requirements.py +1978 -0
- sqlalchemy/testing/schema.py +198 -0
- sqlalchemy/testing/suite/__init__.py +19 -0
- sqlalchemy/testing/suite/test_cte.py +237 -0
- sqlalchemy/testing/suite/test_ddl.py +420 -0
- sqlalchemy/testing/suite/test_dialect.py +776 -0
- sqlalchemy/testing/suite/test_insert.py +630 -0
- sqlalchemy/testing/suite/test_reflection.py +3557 -0
- sqlalchemy/testing/suite/test_results.py +660 -0
- sqlalchemy/testing/suite/test_rowcount.py +258 -0
- sqlalchemy/testing/suite/test_select.py +2112 -0
- sqlalchemy/testing/suite/test_sequence.py +317 -0
- sqlalchemy/testing/suite/test_table_via_select.py +686 -0
- sqlalchemy/testing/suite/test_types.py +2271 -0
- sqlalchemy/testing/suite/test_unicode_ddl.py +189 -0
- sqlalchemy/testing/suite/test_update_delete.py +139 -0
- sqlalchemy/testing/util.py +535 -0
- sqlalchemy/testing/warnings.py +52 -0
- sqlalchemy/types.py +76 -0
- sqlalchemy/util/__init__.py +158 -0
- sqlalchemy/util/_collections.py +688 -0
- sqlalchemy/util/_collections_cy.cp313t-win_arm64.pyd +0 -0
- sqlalchemy/util/_collections_cy.pxd +8 -0
- sqlalchemy/util/_collections_cy.py +516 -0
- sqlalchemy/util/_has_cython.py +46 -0
- sqlalchemy/util/_immutabledict_cy.cp313t-win_arm64.pyd +0 -0
- sqlalchemy/util/_immutabledict_cy.py +240 -0
- sqlalchemy/util/compat.py +299 -0
- sqlalchemy/util/concurrency.py +322 -0
- sqlalchemy/util/cython.py +79 -0
- sqlalchemy/util/deprecations.py +401 -0
- sqlalchemy/util/langhelpers.py +2320 -0
- sqlalchemy/util/preloaded.py +152 -0
- sqlalchemy/util/queue.py +304 -0
- sqlalchemy/util/tool_support.py +201 -0
- sqlalchemy/util/topological.py +120 -0
- sqlalchemy/util/typing.py +711 -0
- sqlalchemy-2.1.0b2.dist-info/METADATA +269 -0
- sqlalchemy-2.1.0b2.dist-info/RECORD +270 -0
- sqlalchemy-2.1.0b2.dist-info/WHEEL +5 -0
- sqlalchemy-2.1.0b2.dist-info/licenses/LICENSE +19 -0
- sqlalchemy-2.1.0b2.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
# sql/__init__.py
|
|
2
|
+
# Copyright (C) 2005-2026 the SQLAlchemy authors and contributors
|
|
3
|
+
# <see AUTHORS file>
|
|
4
|
+
#
|
|
5
|
+
# This module is part of SQLAlchemy and is released under
|
|
6
|
+
# the MIT License: https://www.opensource.org/licenses/mit-license.php
|
|
7
|
+
from typing import Any
|
|
8
|
+
from typing import TYPE_CHECKING
|
|
9
|
+
|
|
10
|
+
from ._typing import ColumnExpressionArgument as ColumnExpressionArgument
|
|
11
|
+
from ._typing import NotNullable as NotNullable
|
|
12
|
+
from ._typing import Nullable as Nullable
|
|
13
|
+
from .base import Executable as Executable
|
|
14
|
+
from .base import ExecutableStatement as ExecutableStatement
|
|
15
|
+
from .base import SyntaxExtension as SyntaxExtension
|
|
16
|
+
from .compiler import COLLECT_CARTESIAN_PRODUCTS as COLLECT_CARTESIAN_PRODUCTS
|
|
17
|
+
from .compiler import FROM_LINTING as FROM_LINTING
|
|
18
|
+
from .compiler import NO_LINTING as NO_LINTING
|
|
19
|
+
from .compiler import WARN_LINTING as WARN_LINTING
|
|
20
|
+
from .ddl import BaseDDLElement as BaseDDLElement
|
|
21
|
+
from .ddl import CheckFirst as CheckFirst
|
|
22
|
+
from .ddl import DDL as DDL
|
|
23
|
+
from .ddl import DDLElement as DDLElement
|
|
24
|
+
from .ddl import ExecutableDDLElement as ExecutableDDLElement
|
|
25
|
+
from .expression import aggregate_order_by as aggregate_order_by
|
|
26
|
+
from .expression import Alias as Alias
|
|
27
|
+
from .expression import alias as alias
|
|
28
|
+
from .expression import all_ as all_
|
|
29
|
+
from .expression import and_ as and_
|
|
30
|
+
from .expression import any_ as any_
|
|
31
|
+
from .expression import asc as asc
|
|
32
|
+
from .expression import between as between
|
|
33
|
+
from .expression import bindparam as bindparam
|
|
34
|
+
from .expression import case as case
|
|
35
|
+
from .expression import cast as cast
|
|
36
|
+
from .expression import ClauseElement as ClauseElement
|
|
37
|
+
from .expression import collate as collate
|
|
38
|
+
from .expression import column as column
|
|
39
|
+
from .expression import ColumnCollection as ColumnCollection
|
|
40
|
+
from .expression import ColumnElement as ColumnElement
|
|
41
|
+
from .expression import CompoundSelect as CompoundSelect
|
|
42
|
+
from .expression import cte as cte
|
|
43
|
+
from .expression import Delete as Delete
|
|
44
|
+
from .expression import delete as delete
|
|
45
|
+
from .expression import desc as desc
|
|
46
|
+
from .expression import distinct as distinct
|
|
47
|
+
from .expression import except_ as except_
|
|
48
|
+
from .expression import except_all as except_all
|
|
49
|
+
from .expression import exists as exists
|
|
50
|
+
from .expression import extract as extract
|
|
51
|
+
from .expression import false as false
|
|
52
|
+
from .expression import False_ as False_
|
|
53
|
+
from .expression import from_dml_column as from_dml_column
|
|
54
|
+
from .expression import FromClause as FromClause
|
|
55
|
+
from .expression import func as func
|
|
56
|
+
from .expression import funcfilter as funcfilter
|
|
57
|
+
from .expression import Insert as Insert
|
|
58
|
+
from .expression import insert as insert
|
|
59
|
+
from .expression import intersect as intersect
|
|
60
|
+
from .expression import intersect_all as intersect_all
|
|
61
|
+
from .expression import Join as Join
|
|
62
|
+
from .expression import join as join
|
|
63
|
+
from .expression import label as label
|
|
64
|
+
from .expression import LABEL_STYLE_DEFAULT as LABEL_STYLE_DEFAULT
|
|
65
|
+
from .expression import (
|
|
66
|
+
LABEL_STYLE_DISAMBIGUATE_ONLY as LABEL_STYLE_DISAMBIGUATE_ONLY,
|
|
67
|
+
)
|
|
68
|
+
from .expression import LABEL_STYLE_NONE as LABEL_STYLE_NONE
|
|
69
|
+
from .expression import (
|
|
70
|
+
LABEL_STYLE_TABLENAME_PLUS_COL as LABEL_STYLE_TABLENAME_PLUS_COL,
|
|
71
|
+
)
|
|
72
|
+
from .expression import lambda_stmt as lambda_stmt
|
|
73
|
+
from .expression import LambdaElement as LambdaElement
|
|
74
|
+
from .expression import lateral as lateral
|
|
75
|
+
from .expression import literal as literal
|
|
76
|
+
from .expression import literal_column as literal_column
|
|
77
|
+
from .expression import modifier as modifier
|
|
78
|
+
from .expression import not_ as not_
|
|
79
|
+
from .expression import null as null
|
|
80
|
+
from .expression import nulls_first as nulls_first
|
|
81
|
+
from .expression import nulls_last as nulls_last
|
|
82
|
+
from .expression import nullsfirst as nullsfirst
|
|
83
|
+
from .expression import nullslast as nullslast
|
|
84
|
+
from .expression import or_ as or_
|
|
85
|
+
from .expression import outerjoin as outerjoin
|
|
86
|
+
from .expression import outparam as outparam
|
|
87
|
+
from .expression import over as over
|
|
88
|
+
from .expression import quoted_name as quoted_name
|
|
89
|
+
from .expression import Select as Select
|
|
90
|
+
from .expression import select as select
|
|
91
|
+
from .expression import Selectable as Selectable
|
|
92
|
+
from .expression import SelectLabelStyle as SelectLabelStyle
|
|
93
|
+
from .expression import SQLColumnExpression as SQLColumnExpression
|
|
94
|
+
from .expression import StatementLambdaElement as StatementLambdaElement
|
|
95
|
+
from .expression import Subquery as Subquery
|
|
96
|
+
from .expression import table as table
|
|
97
|
+
from .expression import TableClause as TableClause
|
|
98
|
+
from .expression import TableSample as TableSample
|
|
99
|
+
from .expression import tablesample as tablesample
|
|
100
|
+
from .expression import TableValuedAlias as TableValuedAlias
|
|
101
|
+
from .expression import TableValuedColumn as TableValuedColumn
|
|
102
|
+
from .expression import text as text
|
|
103
|
+
from .expression import TextClause as TextClause
|
|
104
|
+
from .expression import true as true
|
|
105
|
+
from .expression import True_ as True_
|
|
106
|
+
from .expression import try_cast as try_cast
|
|
107
|
+
from .expression import TString as TString
|
|
108
|
+
from .expression import tstring as tstring
|
|
109
|
+
from .expression import tuple_ as tuple_
|
|
110
|
+
from .expression import type_coerce as type_coerce
|
|
111
|
+
from .expression import union as union
|
|
112
|
+
from .expression import union_all as union_all
|
|
113
|
+
from .expression import Update as Update
|
|
114
|
+
from .expression import update as update
|
|
115
|
+
from .expression import Values as Values
|
|
116
|
+
from .expression import values as values
|
|
117
|
+
from .expression import within_group as within_group
|
|
118
|
+
from .expression import WriteableColumnCollection as WriteableColumnCollection
|
|
119
|
+
from .visitors import ClauseVisitor as ClauseVisitor
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def __go(lcls: Any) -> None:
|
|
123
|
+
from .. import util as _sa_util
|
|
124
|
+
|
|
125
|
+
from . import base
|
|
126
|
+
from . import coercions
|
|
127
|
+
from . import elements
|
|
128
|
+
from . import lambdas
|
|
129
|
+
from . import selectable
|
|
130
|
+
from . import schema
|
|
131
|
+
from . import traversals
|
|
132
|
+
from . import type_api
|
|
133
|
+
|
|
134
|
+
if not TYPE_CHECKING:
|
|
135
|
+
base.coercions = elements.coercions = coercions
|
|
136
|
+
base.elements = elements
|
|
137
|
+
base.type_api = type_api
|
|
138
|
+
coercions.elements = elements
|
|
139
|
+
coercions.lambdas = lambdas
|
|
140
|
+
coercions.schema = schema
|
|
141
|
+
coercions.selectable = selectable
|
|
142
|
+
|
|
143
|
+
from .annotation import _prepare_annotations
|
|
144
|
+
from .annotation import Annotated
|
|
145
|
+
from .elements import AnnotatedColumnElement
|
|
146
|
+
from .elements import ClauseList
|
|
147
|
+
from .selectable import AnnotatedFromClause
|
|
148
|
+
|
|
149
|
+
_prepare_annotations(ColumnElement, AnnotatedColumnElement)
|
|
150
|
+
_prepare_annotations(FromClause, AnnotatedFromClause)
|
|
151
|
+
_prepare_annotations(ClauseList, Annotated)
|
|
152
|
+
|
|
153
|
+
_sa_util.preloaded.import_prefix("sqlalchemy.sql")
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
__go(locals())
|
|
@@ -0,0 +1,397 @@
|
|
|
1
|
+
# sql/_annotated_cols.py
|
|
2
|
+
# Copyright (C) 2005-2026 the SQLAlchemy authors and contributors
|
|
3
|
+
# <see AUTHORS file>
|
|
4
|
+
#
|
|
5
|
+
# This module is part of SQLAlchemy and is released under
|
|
6
|
+
# the MIT License: https://www.opensource.org/licenses/mit-license.php
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from typing import Any
|
|
10
|
+
from typing import Generic
|
|
11
|
+
from typing import Literal
|
|
12
|
+
from typing import NoReturn
|
|
13
|
+
from typing import overload
|
|
14
|
+
from typing import Protocol
|
|
15
|
+
from typing import TYPE_CHECKING
|
|
16
|
+
|
|
17
|
+
from . import sqltypes
|
|
18
|
+
from ._typing import _T
|
|
19
|
+
from ._typing import _Ts
|
|
20
|
+
from .base import _NoArg
|
|
21
|
+
from .base import ReadOnlyColumnCollection
|
|
22
|
+
from .. import util
|
|
23
|
+
from ..exc import ArgumentError
|
|
24
|
+
from ..exc import InvalidRequestError
|
|
25
|
+
from ..util import typing as sa_typing
|
|
26
|
+
from ..util.langhelpers import dunders_re
|
|
27
|
+
from ..util.typing import Never
|
|
28
|
+
from ..util.typing import Self
|
|
29
|
+
from ..util.typing import TypeVar
|
|
30
|
+
from ..util.typing import Unpack
|
|
31
|
+
|
|
32
|
+
if TYPE_CHECKING:
|
|
33
|
+
from .elements import ColumnClause # noqa (for zimports)
|
|
34
|
+
from .elements import KeyedColumnElement # noqa (for zimports)
|
|
35
|
+
from .schema import Column
|
|
36
|
+
from .type_api import TypeEngine
|
|
37
|
+
from ..util.typing import _AnnotationScanType
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class Named(Generic[_T]):
|
|
41
|
+
"""A named descriptor that is interpreted by SQLAlchemy in various ways.
|
|
42
|
+
|
|
43
|
+
.. seealso::
|
|
44
|
+
|
|
45
|
+
:class:`_schema.TypedColumns` Define table columns using this
|
|
46
|
+
descriptor.
|
|
47
|
+
|
|
48
|
+
.. versionadded:: 2.1.0b2
|
|
49
|
+
"""
|
|
50
|
+
|
|
51
|
+
__slots__ = ()
|
|
52
|
+
|
|
53
|
+
key: str
|
|
54
|
+
if TYPE_CHECKING:
|
|
55
|
+
|
|
56
|
+
# NOTE: this overload prevents users from using the a TypedColumns
|
|
57
|
+
# class like if it were an orm mapped class
|
|
58
|
+
@overload
|
|
59
|
+
def __get__(self, instance: None, owner: Any) -> Never: ...
|
|
60
|
+
|
|
61
|
+
@overload
|
|
62
|
+
def __get__(
|
|
63
|
+
self, instance: TypedColumns, owner: Any
|
|
64
|
+
) -> Column[_T]: ...
|
|
65
|
+
@overload
|
|
66
|
+
def __get__(self, instance: Any, owner: Any) -> Self: ...
|
|
67
|
+
|
|
68
|
+
def __get__(self, instance: object | None, owner: Any) -> Any: ...
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
# NOTE: TypedColumns subclasses are ignored by the ORM mapping process
|
|
72
|
+
class TypedColumns(ReadOnlyColumnCollection[str, "Column[Any]"]):
|
|
73
|
+
"""Class that generally represent the typed columns of a :class:`.Table`,
|
|
74
|
+
but can be used with most :class:`_sql.FromClause` subclasses with the
|
|
75
|
+
:meth:`_sql.FromClause.with_cols` method.
|
|
76
|
+
|
|
77
|
+
This is a "typing only" class that is never instantiated at runtime: the
|
|
78
|
+
type checker will think that this class is exposed as the ``table.c``
|
|
79
|
+
attribute, but in reality a normal :class:`_schema.ColumnCollection` is
|
|
80
|
+
used at runtime.
|
|
81
|
+
|
|
82
|
+
Subclasses should just list the columns as class attributes, without
|
|
83
|
+
specifying method or other non column members.
|
|
84
|
+
|
|
85
|
+
To resolve the columns, a simplified version of the ORM logic is used,
|
|
86
|
+
in particular, columns can be declared by:
|
|
87
|
+
|
|
88
|
+
* directly instantiating them, to declare constraint, custom SQL types and
|
|
89
|
+
additional column options;
|
|
90
|
+
* using only a :class:`.Named` or :class:`_schema.Column` type annotation,
|
|
91
|
+
where nullability and SQL type will be inferred by the python type
|
|
92
|
+
provided.
|
|
93
|
+
Type inference is available for a common subset of python types.
|
|
94
|
+
* a mix of both, where the instance can be used to declare
|
|
95
|
+
constraints and other column options while the annotation will be used
|
|
96
|
+
to set the SQL type and nullability if not provided by the instance.
|
|
97
|
+
|
|
98
|
+
In all cases the name is inferred from the attribute name, unless
|
|
99
|
+
explicitly provided.
|
|
100
|
+
|
|
101
|
+
.. note::
|
|
102
|
+
|
|
103
|
+
The generated table will create a copy of any column instance assigned
|
|
104
|
+
as attributes of this class, so columns should be accessed only via
|
|
105
|
+
the ``table.c`` collection, not using this class directly.
|
|
106
|
+
|
|
107
|
+
Example of the inference behavior::
|
|
108
|
+
|
|
109
|
+
from sqlalchemy import Column, Integer, Named, String, TypedColumns
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
class tbl_cols(TypedColumns):
|
|
113
|
+
# the name will be set to ``id``, type is inferred as Column[int]
|
|
114
|
+
id = Column(Integer, primary_key=True)
|
|
115
|
+
|
|
116
|
+
# not null String column is generated
|
|
117
|
+
name: Named[str]
|
|
118
|
+
|
|
119
|
+
# nullable Double column is generated
|
|
120
|
+
weight: Named[float | None]
|
|
121
|
+
|
|
122
|
+
# nullable Integer column, with sql name 'user_age'
|
|
123
|
+
age: Named[int | None] = Column("user_age")
|
|
124
|
+
|
|
125
|
+
# not null column with type String(42)
|
|
126
|
+
middle_name: Named[str] = Column(String(42))
|
|
127
|
+
|
|
128
|
+
Mixins and subclasses are also supported::
|
|
129
|
+
|
|
130
|
+
class with_id(TypedColumns):
|
|
131
|
+
id = Column(Integer, primary_key=True)
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
class named_cols(TypedColumns):
|
|
135
|
+
name: Named[str]
|
|
136
|
+
description: Named[str | None]
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
class product_cols(named_cols, with_id):
|
|
140
|
+
ean: Named[str] = Column(unique=True)
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
product = Table("product", metadata, product_cols)
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
class office_cols(named_cols, with_id):
|
|
147
|
+
address: Named[str]
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
office = Table("office", metadata, office_cols)
|
|
151
|
+
|
|
152
|
+
The positional types returned when selecting the table can
|
|
153
|
+
be optionally declared by specifying a :attr:`.HasRowPos.__row_pos__`
|
|
154
|
+
annotation::
|
|
155
|
+
|
|
156
|
+
from sqlalchemy import select
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
class some_cols(TypedColumns):
|
|
160
|
+
id = Column(Integer, primary_key=True)
|
|
161
|
+
name: Named[str]
|
|
162
|
+
weight: Named[float | None]
|
|
163
|
+
|
|
164
|
+
__row_pos__: tuple[int, str, float | None]
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
some_table = Table("st", metadata, some_cols)
|
|
168
|
+
|
|
169
|
+
# both will be typed as Select[int, str, float | None]
|
|
170
|
+
stmt1 = some_table.select()
|
|
171
|
+
stmt2 = select(some_table)
|
|
172
|
+
|
|
173
|
+
.. seealso::
|
|
174
|
+
|
|
175
|
+
:class:`.Table` for usage details on how to use this class to
|
|
176
|
+
create a table instance.
|
|
177
|
+
|
|
178
|
+
:meth:`_sql.FromClause.with_cols` to apply a :class:`.TypedColumns`
|
|
179
|
+
to a from clause.
|
|
180
|
+
|
|
181
|
+
.. versionadded:: 2.1.0b2
|
|
182
|
+
""" # noqa
|
|
183
|
+
|
|
184
|
+
__slots__ = ()
|
|
185
|
+
|
|
186
|
+
if not TYPE_CHECKING:
|
|
187
|
+
|
|
188
|
+
def __new__(cls, *args: Any, **kwargs: Any) -> NoReturn:
|
|
189
|
+
raise InvalidRequestError(
|
|
190
|
+
"Cannot instantiate a TypedColumns object."
|
|
191
|
+
)
|
|
192
|
+
|
|
193
|
+
def __init_subclass__(cls) -> None:
|
|
194
|
+
methods = {
|
|
195
|
+
name
|
|
196
|
+
for name, value in cls.__dict__.items()
|
|
197
|
+
if not dunders_re.match(name) and callable(value)
|
|
198
|
+
}
|
|
199
|
+
if methods:
|
|
200
|
+
raise InvalidRequestError(
|
|
201
|
+
"TypedColumns subclasses may not define methods. "
|
|
202
|
+
f"Found {sorted(methods)}"
|
|
203
|
+
)
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
_KeyColCC_co = TypeVar(
|
|
207
|
+
"_KeyColCC_co",
|
|
208
|
+
bound=ReadOnlyColumnCollection[str, "KeyedColumnElement[Any]"],
|
|
209
|
+
covariant=True,
|
|
210
|
+
default=ReadOnlyColumnCollection[str, "KeyedColumnElement[Any]"],
|
|
211
|
+
)
|
|
212
|
+
_ColClauseCC_co = TypeVar(
|
|
213
|
+
"_ColClauseCC_co",
|
|
214
|
+
bound=ReadOnlyColumnCollection[str, "ColumnClause[Any]"],
|
|
215
|
+
covariant=True,
|
|
216
|
+
default=ReadOnlyColumnCollection[str, "ColumnClause[Any]"],
|
|
217
|
+
)
|
|
218
|
+
_ColCC_co = TypeVar(
|
|
219
|
+
"_ColCC_co",
|
|
220
|
+
bound=ReadOnlyColumnCollection[str, "Column[Any]"],
|
|
221
|
+
covariant=True,
|
|
222
|
+
default=ReadOnlyColumnCollection[str, "Column[Any]"],
|
|
223
|
+
)
|
|
224
|
+
|
|
225
|
+
_TC = TypeVar("_TC", bound=TypedColumns)
|
|
226
|
+
_TC_co = TypeVar("_TC_co", bound=TypedColumns, covariant=True)
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
class HasRowPos(Protocol[Unpack[_Ts]]):
|
|
230
|
+
"""Protocol for a :class:`_schema.TypedColumns` used to indicate the
|
|
231
|
+
positional types will be returned when selecting the table.
|
|
232
|
+
|
|
233
|
+
.. versionadded:: 2.1.0b2
|
|
234
|
+
"""
|
|
235
|
+
|
|
236
|
+
__row_pos__: tuple[Unpack[_Ts]]
|
|
237
|
+
"""A tuple that represents the types that will be returned when
|
|
238
|
+
selecting from the table.
|
|
239
|
+
"""
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
@util.preload_module("sqlalchemy.sql.schema")
|
|
243
|
+
def _extract_columns_from_class(
|
|
244
|
+
table_columns_cls: type[TypedColumns],
|
|
245
|
+
) -> list[Column[Any]]:
|
|
246
|
+
columns: dict[str, Column[Any]] = {}
|
|
247
|
+
|
|
248
|
+
Column = util.preloaded.sql_schema.Column
|
|
249
|
+
NULL_UNSPECIFIED = util.preloaded.sql_schema.NULL_UNSPECIFIED
|
|
250
|
+
|
|
251
|
+
for base in table_columns_cls.__mro__[::-1]:
|
|
252
|
+
if base in TypedColumns.__mro__:
|
|
253
|
+
continue
|
|
254
|
+
|
|
255
|
+
# _ClassScanAbstractConfig._cls_attr_resolver
|
|
256
|
+
cls_annotations = util.get_annotations(base)
|
|
257
|
+
cls_vars = vars(base)
|
|
258
|
+
items = [
|
|
259
|
+
(n, cls_vars.get(n), cls_annotations.get(n))
|
|
260
|
+
for n in util.merge_lists_w_ordering(
|
|
261
|
+
list(cls_vars), list(cls_annotations)
|
|
262
|
+
)
|
|
263
|
+
if not dunders_re.match(n)
|
|
264
|
+
]
|
|
265
|
+
# --
|
|
266
|
+
for name, obj, annotation in items:
|
|
267
|
+
if obj is None:
|
|
268
|
+
assert annotation is not None
|
|
269
|
+
# no attribute, just annotation
|
|
270
|
+
extracted_type = _collect_annotation(
|
|
271
|
+
table_columns_cls, name, base.__module__, annotation
|
|
272
|
+
)
|
|
273
|
+
if extracted_type is _NoArg.NO_ARG:
|
|
274
|
+
raise ArgumentError(
|
|
275
|
+
"No type information could be extracted from "
|
|
276
|
+
f"annotation {annotation} for attribute "
|
|
277
|
+
f"'{base.__name__}.{name}'"
|
|
278
|
+
)
|
|
279
|
+
sqltype = _get_sqltype(extracted_type)
|
|
280
|
+
if sqltype is None:
|
|
281
|
+
raise ArgumentError(
|
|
282
|
+
f"Could not find a SQL type for type {extracted_type} "
|
|
283
|
+
f"obtained from annotation {annotation} in "
|
|
284
|
+
f"attribute '{base.__name__}.{name}'"
|
|
285
|
+
)
|
|
286
|
+
columns[name] = Column(
|
|
287
|
+
name,
|
|
288
|
+
sqltype,
|
|
289
|
+
nullable=sa_typing.includes_none(extracted_type),
|
|
290
|
+
)
|
|
291
|
+
elif isinstance(obj, Column):
|
|
292
|
+
# has attribute attribute
|
|
293
|
+
# _DeclarativeMapperConfig._produce_column_copies
|
|
294
|
+
# as with orm this case is not supported
|
|
295
|
+
for fk in obj.foreign_keys:
|
|
296
|
+
if (
|
|
297
|
+
fk._table_column is not None
|
|
298
|
+
and fk._table_column.table is None
|
|
299
|
+
):
|
|
300
|
+
raise InvalidRequestError(
|
|
301
|
+
f"Column '{base.__name__}.{name}' with foreign "
|
|
302
|
+
"key to non-table-bound columns is not supported "
|
|
303
|
+
"when using a TypedColumns. If possible use the "
|
|
304
|
+
"qualified string name the column"
|
|
305
|
+
)
|
|
306
|
+
|
|
307
|
+
col = obj._copy()
|
|
308
|
+
# MapptedColumn.declarative_scan
|
|
309
|
+
if col.key == col.name and col.key != name:
|
|
310
|
+
col.key = name
|
|
311
|
+
if col.name is None:
|
|
312
|
+
col.name = name
|
|
313
|
+
|
|
314
|
+
sqltype = col.type
|
|
315
|
+
anno_sqltype = None
|
|
316
|
+
nullable: Literal[_NoArg.NO_ARG] | bool = _NoArg.NO_ARG
|
|
317
|
+
if annotation is not None:
|
|
318
|
+
# there is an annotation, extract the type
|
|
319
|
+
extracted_type = _collect_annotation(
|
|
320
|
+
table_columns_cls, name, base.__module__, annotation
|
|
321
|
+
)
|
|
322
|
+
if extracted_type is not _NoArg.NO_ARG:
|
|
323
|
+
anno_sqltype = _get_sqltype(extracted_type)
|
|
324
|
+
nullable = sa_typing.includes_none(extracted_type)
|
|
325
|
+
|
|
326
|
+
if sqltype._isnull:
|
|
327
|
+
if anno_sqltype is None and not col.foreign_keys:
|
|
328
|
+
raise ArgumentError(
|
|
329
|
+
"Python typing annotation is required for "
|
|
330
|
+
f"attribute '{base.__name__}.{name}' when "
|
|
331
|
+
"primary argument(s) for Column construct are "
|
|
332
|
+
"None or not present"
|
|
333
|
+
)
|
|
334
|
+
elif anno_sqltype is not None:
|
|
335
|
+
col._set_type(anno_sqltype)
|
|
336
|
+
|
|
337
|
+
if (
|
|
338
|
+
nullable is not _NoArg.NO_ARG
|
|
339
|
+
and col._user_defined_nullable is NULL_UNSPECIFIED
|
|
340
|
+
and not col.primary_key
|
|
341
|
+
):
|
|
342
|
+
col.nullable = nullable
|
|
343
|
+
columns[name] = col
|
|
344
|
+
else:
|
|
345
|
+
raise ArgumentError(
|
|
346
|
+
f"Unexpected value for attribute '{base.__name__}.{name}'"
|
|
347
|
+
f". Expected a Column, not: {type(obj)}"
|
|
348
|
+
)
|
|
349
|
+
|
|
350
|
+
# Return columns as a list
|
|
351
|
+
return list(columns.values())
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
@util.preload_module("sqlalchemy.sql.schema")
|
|
355
|
+
def _collect_annotation(
|
|
356
|
+
cls: type[Any], name: str, module: str, raw_annotation: _AnnotationScanType
|
|
357
|
+
) -> _AnnotationScanType | Literal[_NoArg.NO_ARG]:
|
|
358
|
+
Column = util.preloaded.sql_schema.Column
|
|
359
|
+
|
|
360
|
+
_locals = {"Column": Column, "Named": Named}
|
|
361
|
+
# _ClassScanAbstractConfig._collect_annotation & _extract_mapped_subtype
|
|
362
|
+
try:
|
|
363
|
+
annotation = sa_typing.de_stringify_annotation(
|
|
364
|
+
cls, raw_annotation, module, _locals
|
|
365
|
+
)
|
|
366
|
+
except Exception as e:
|
|
367
|
+
raise ArgumentError(
|
|
368
|
+
f"Could not interpret annotation {raw_annotation} for "
|
|
369
|
+
f"attribute '{cls.__name__}.{name}'"
|
|
370
|
+
) from e
|
|
371
|
+
|
|
372
|
+
if (
|
|
373
|
+
not sa_typing.is_generic(annotation)
|
|
374
|
+
and isinstance(annotation, type)
|
|
375
|
+
and issubclass(annotation, (Column, Named))
|
|
376
|
+
):
|
|
377
|
+
# no generic information, ignore
|
|
378
|
+
return _NoArg.NO_ARG
|
|
379
|
+
elif not sa_typing.is_origin_of_cls(annotation, (Column, Named)):
|
|
380
|
+
raise ArgumentError(
|
|
381
|
+
f"Annotation {raw_annotation} for attribute "
|
|
382
|
+
f"'{cls.__name__}.{name}' is not of type Named/Column[...]"
|
|
383
|
+
)
|
|
384
|
+
else:
|
|
385
|
+
assert len(annotation.__args__) == 1 # Column[int, int] raises
|
|
386
|
+
return annotation.__args__[0] # type: ignore[no-any-return]
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
def _get_sqltype(annotation: _AnnotationScanType) -> TypeEngine[Any] | None:
|
|
390
|
+
our_type = sa_typing.de_optionalize_union_types(annotation)
|
|
391
|
+
# simplified version of registry._resolve_type given no customizable
|
|
392
|
+
# type map
|
|
393
|
+
sql_type = sqltypes._type_map_get(our_type) # type: ignore[arg-type]
|
|
394
|
+
if sql_type is not None and not sql_type._isnull:
|
|
395
|
+
return sqltypes.to_instance(sql_type)
|
|
396
|
+
else:
|
|
397
|
+
return None
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# sql/_dml_constructors.py
|
|
2
|
+
# Copyright (C) 2005-2026 the SQLAlchemy authors and contributors
|
|
3
|
+
# <see AUTHORS file>
|
|
4
|
+
#
|
|
5
|
+
# This module is part of SQLAlchemy and is released under
|
|
6
|
+
# the MIT License: https://www.opensource.org/licenses/mit-license.php
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
from typing import TYPE_CHECKING
|
|
11
|
+
|
|
12
|
+
from .dml import Delete
|
|
13
|
+
from .dml import Insert
|
|
14
|
+
from .dml import Update
|
|
15
|
+
|
|
16
|
+
if TYPE_CHECKING:
|
|
17
|
+
from ._typing import _DMLTableArgument
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def insert(table: _DMLTableArgument) -> Insert:
|
|
21
|
+
"""Construct an :class:`_expression.Insert` object.
|
|
22
|
+
|
|
23
|
+
E.g.::
|
|
24
|
+
|
|
25
|
+
from sqlalchemy import insert
|
|
26
|
+
|
|
27
|
+
stmt = insert(user_table).values(name="username", fullname="Full Username")
|
|
28
|
+
|
|
29
|
+
Similar functionality is available via the
|
|
30
|
+
:meth:`_expression.TableClause.insert` method on
|
|
31
|
+
:class:`_schema.Table`.
|
|
32
|
+
|
|
33
|
+
.. seealso::
|
|
34
|
+
|
|
35
|
+
:ref:`tutorial_core_insert` - in the :ref:`unified_tutorial`
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
:param table: :class:`_expression.TableClause`
|
|
39
|
+
which is the subject of the
|
|
40
|
+
insert.
|
|
41
|
+
|
|
42
|
+
:param values: collection of values to be inserted; see
|
|
43
|
+
:meth:`_expression.Insert.values`
|
|
44
|
+
for a description of allowed formats here.
|
|
45
|
+
Can be omitted entirely; a :class:`_expression.Insert` construct
|
|
46
|
+
will also dynamically render the VALUES clause at execution time
|
|
47
|
+
based on the parameters passed to :meth:`_engine.Connection.execute`.
|
|
48
|
+
|
|
49
|
+
:param inline: if True, no attempt will be made to retrieve the
|
|
50
|
+
SQL-generated default values to be provided within the statement;
|
|
51
|
+
in particular,
|
|
52
|
+
this allows SQL expressions to be rendered 'inline' within the
|
|
53
|
+
statement without the need to pre-execute them beforehand; for
|
|
54
|
+
backends that support "returning", this turns off the "implicit
|
|
55
|
+
returning" feature for the statement.
|
|
56
|
+
|
|
57
|
+
If both :paramref:`_expression.insert.values` and compile-time bind
|
|
58
|
+
parameters are present, the compile-time bind parameters override the
|
|
59
|
+
information specified within :paramref:`_expression.insert.values` on a
|
|
60
|
+
per-key basis.
|
|
61
|
+
|
|
62
|
+
The keys within :paramref:`_expression.Insert.values` can be either
|
|
63
|
+
:class:`~sqlalchemy.schema.Column` objects or their string
|
|
64
|
+
identifiers. Each key may reference one of:
|
|
65
|
+
|
|
66
|
+
* a literal data value (i.e. string, number, etc.);
|
|
67
|
+
* a Column object;
|
|
68
|
+
* a SELECT statement.
|
|
69
|
+
|
|
70
|
+
If a ``SELECT`` statement is specified which references this
|
|
71
|
+
``INSERT`` statement's table, the statement will be correlated
|
|
72
|
+
against the ``INSERT`` statement.
|
|
73
|
+
|
|
74
|
+
.. seealso::
|
|
75
|
+
|
|
76
|
+
:ref:`tutorial_core_insert` - in the :ref:`unified_tutorial`
|
|
77
|
+
|
|
78
|
+
""" # noqa: E501
|
|
79
|
+
return Insert(table)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def update(table: _DMLTableArgument) -> Update:
|
|
83
|
+
r"""Construct an :class:`_expression.Update` object.
|
|
84
|
+
|
|
85
|
+
E.g.::
|
|
86
|
+
|
|
87
|
+
from sqlalchemy import update
|
|
88
|
+
|
|
89
|
+
stmt = (
|
|
90
|
+
update(user_table).where(user_table.c.id == 5).values(name="user #5")
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
Similar functionality is available via the
|
|
94
|
+
:meth:`_expression.TableClause.update` method on
|
|
95
|
+
:class:`_schema.Table`.
|
|
96
|
+
|
|
97
|
+
:param table: A :class:`_schema.Table`
|
|
98
|
+
object representing the database
|
|
99
|
+
table to be updated.
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
.. seealso::
|
|
103
|
+
|
|
104
|
+
:ref:`tutorial_core_update_delete` - in the :ref:`unified_tutorial`
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
""" # noqa: E501
|
|
108
|
+
return Update(table)
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def delete(table: _DMLTableArgument) -> Delete:
|
|
112
|
+
r"""Construct :class:`_expression.Delete` object.
|
|
113
|
+
|
|
114
|
+
E.g.::
|
|
115
|
+
|
|
116
|
+
from sqlalchemy import delete
|
|
117
|
+
|
|
118
|
+
stmt = delete(user_table).where(user_table.c.id == 5)
|
|
119
|
+
|
|
120
|
+
Similar functionality is available via the
|
|
121
|
+
:meth:`_expression.TableClause.delete` method on
|
|
122
|
+
:class:`_schema.Table`.
|
|
123
|
+
|
|
124
|
+
:param table: The table to delete rows from.
|
|
125
|
+
|
|
126
|
+
.. seealso::
|
|
127
|
+
|
|
128
|
+
:ref:`tutorial_core_update_delete` - in the :ref:`unified_tutorial`
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
"""
|
|
132
|
+
return Delete(table)
|