Загрузить файлы в «venv/Lib/site-packages/sqlalchemy/sql»
This commit is contained in:
145
venv/Lib/site-packages/sqlalchemy/sql/__init__.py
Normal file
145
venv/Lib/site-packages/sqlalchemy/sql/__init__.py
Normal file
@@ -0,0 +1,145 @@
|
|||||||
|
# sql/__init__.py
|
||||||
|
# Copyright (C) 2005-2026 the SQLAlchemy authors and contributors
|
||||||
|
# <see AUTHORS file>
|
||||||
|
#
|
||||||
|
# This module is part of SQLAlchemy and is released under
|
||||||
|
# the MIT License: https://www.opensource.org/licenses/mit-license.php
|
||||||
|
from typing import Any
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
|
from ._typing import ColumnExpressionArgument as ColumnExpressionArgument
|
||||||
|
from ._typing import NotNullable as NotNullable
|
||||||
|
from ._typing import Nullable as Nullable
|
||||||
|
from .base import Executable as Executable
|
||||||
|
from .compiler import COLLECT_CARTESIAN_PRODUCTS as COLLECT_CARTESIAN_PRODUCTS
|
||||||
|
from .compiler import FROM_LINTING as FROM_LINTING
|
||||||
|
from .compiler import NO_LINTING as NO_LINTING
|
||||||
|
from .compiler import WARN_LINTING as WARN_LINTING
|
||||||
|
from .ddl import BaseDDLElement as BaseDDLElement
|
||||||
|
from .ddl import DDL as DDL
|
||||||
|
from .ddl import DDLElement as DDLElement
|
||||||
|
from .ddl import ExecutableDDLElement as ExecutableDDLElement
|
||||||
|
from .expression import Alias as Alias
|
||||||
|
from .expression import alias as alias
|
||||||
|
from .expression import all_ as all_
|
||||||
|
from .expression import and_ as and_
|
||||||
|
from .expression import any_ as any_
|
||||||
|
from .expression import asc as asc
|
||||||
|
from .expression import between as between
|
||||||
|
from .expression import bindparam as bindparam
|
||||||
|
from .expression import case as case
|
||||||
|
from .expression import cast as cast
|
||||||
|
from .expression import ClauseElement as ClauseElement
|
||||||
|
from .expression import collate as collate
|
||||||
|
from .expression import column as column
|
||||||
|
from .expression import ColumnCollection as ColumnCollection
|
||||||
|
from .expression import ColumnElement as ColumnElement
|
||||||
|
from .expression import CompoundSelect as CompoundSelect
|
||||||
|
from .expression import cte as cte
|
||||||
|
from .expression import Delete as Delete
|
||||||
|
from .expression import delete as delete
|
||||||
|
from .expression import desc as desc
|
||||||
|
from .expression import distinct as distinct
|
||||||
|
from .expression import except_ as except_
|
||||||
|
from .expression import except_all as except_all
|
||||||
|
from .expression import exists as exists
|
||||||
|
from .expression import extract as extract
|
||||||
|
from .expression import false as false
|
||||||
|
from .expression import False_ as False_
|
||||||
|
from .expression import FromClause as FromClause
|
||||||
|
from .expression import func as func
|
||||||
|
from .expression import funcfilter as funcfilter
|
||||||
|
from .expression import Insert as Insert
|
||||||
|
from .expression import insert as insert
|
||||||
|
from .expression import intersect as intersect
|
||||||
|
from .expression import intersect_all as intersect_all
|
||||||
|
from .expression import Join as Join
|
||||||
|
from .expression import join as join
|
||||||
|
from .expression import label as label
|
||||||
|
from .expression import LABEL_STYLE_DEFAULT as LABEL_STYLE_DEFAULT
|
||||||
|
from .expression import (
|
||||||
|
LABEL_STYLE_DISAMBIGUATE_ONLY as LABEL_STYLE_DISAMBIGUATE_ONLY,
|
||||||
|
)
|
||||||
|
from .expression import LABEL_STYLE_NONE as LABEL_STYLE_NONE
|
||||||
|
from .expression import (
|
||||||
|
LABEL_STYLE_TABLENAME_PLUS_COL as LABEL_STYLE_TABLENAME_PLUS_COL,
|
||||||
|
)
|
||||||
|
from .expression import lambda_stmt as lambda_stmt
|
||||||
|
from .expression import LambdaElement as LambdaElement
|
||||||
|
from .expression import lateral as lateral
|
||||||
|
from .expression import literal as literal
|
||||||
|
from .expression import literal_column as literal_column
|
||||||
|
from .expression import modifier as modifier
|
||||||
|
from .expression import not_ as not_
|
||||||
|
from .expression import null as null
|
||||||
|
from .expression import nulls_first as nulls_first
|
||||||
|
from .expression import nulls_last as nulls_last
|
||||||
|
from .expression import nullsfirst as nullsfirst
|
||||||
|
from .expression import nullslast as nullslast
|
||||||
|
from .expression import or_ as or_
|
||||||
|
from .expression import outerjoin as outerjoin
|
||||||
|
from .expression import outparam as outparam
|
||||||
|
from .expression import over as over
|
||||||
|
from .expression import quoted_name as quoted_name
|
||||||
|
from .expression import Select as Select
|
||||||
|
from .expression import select as select
|
||||||
|
from .expression import Selectable as Selectable
|
||||||
|
from .expression import SelectLabelStyle as SelectLabelStyle
|
||||||
|
from .expression import SQLColumnExpression as SQLColumnExpression
|
||||||
|
from .expression import StatementLambdaElement as StatementLambdaElement
|
||||||
|
from .expression import Subquery as Subquery
|
||||||
|
from .expression import table as table
|
||||||
|
from .expression import TableClause as TableClause
|
||||||
|
from .expression import TableSample as TableSample
|
||||||
|
from .expression import tablesample as tablesample
|
||||||
|
from .expression import text as text
|
||||||
|
from .expression import true as true
|
||||||
|
from .expression import True_ as True_
|
||||||
|
from .expression import try_cast as try_cast
|
||||||
|
from .expression import tuple_ as tuple_
|
||||||
|
from .expression import type_coerce as type_coerce
|
||||||
|
from .expression import union as union
|
||||||
|
from .expression import union_all as union_all
|
||||||
|
from .expression import Update as Update
|
||||||
|
from .expression import update as update
|
||||||
|
from .expression import Values as Values
|
||||||
|
from .expression import values as values
|
||||||
|
from .expression import within_group as within_group
|
||||||
|
from .visitors import ClauseVisitor as ClauseVisitor
|
||||||
|
|
||||||
|
|
||||||
|
def __go(lcls: Any) -> None:
|
||||||
|
from .. import util as _sa_util
|
||||||
|
|
||||||
|
from . import base
|
||||||
|
from . import coercions
|
||||||
|
from . import elements
|
||||||
|
from . import lambdas
|
||||||
|
from . import selectable
|
||||||
|
from . import schema
|
||||||
|
from . import traversals
|
||||||
|
from . import type_api
|
||||||
|
|
||||||
|
if not TYPE_CHECKING:
|
||||||
|
base.coercions = elements.coercions = coercions
|
||||||
|
base.elements = elements
|
||||||
|
base.type_api = type_api
|
||||||
|
coercions.elements = elements
|
||||||
|
coercions.lambdas = lambdas
|
||||||
|
coercions.schema = schema
|
||||||
|
coercions.selectable = selectable
|
||||||
|
|
||||||
|
from .annotation import _prepare_annotations
|
||||||
|
from .annotation import Annotated
|
||||||
|
from .elements import AnnotatedColumnElement
|
||||||
|
from .elements import ClauseList
|
||||||
|
from .selectable import AnnotatedFromClause
|
||||||
|
|
||||||
|
_prepare_annotations(ColumnElement, AnnotatedColumnElement)
|
||||||
|
_prepare_annotations(FromClause, AnnotatedFromClause)
|
||||||
|
_prepare_annotations(ClauseList, Annotated)
|
||||||
|
|
||||||
|
_sa_util.preloaded.import_prefix("sqlalchemy.sql")
|
||||||
|
|
||||||
|
|
||||||
|
__go(locals())
|
||||||
132
venv/Lib/site-packages/sqlalchemy/sql/_dml_constructors.py
Normal file
132
venv/Lib/site-packages/sqlalchemy/sql/_dml_constructors.py
Normal file
@@ -0,0 +1,132 @@
|
|||||||
|
# sql/_dml_constructors.py
|
||||||
|
# Copyright (C) 2005-2026 the SQLAlchemy authors and contributors
|
||||||
|
# <see AUTHORS file>
|
||||||
|
#
|
||||||
|
# This module is part of SQLAlchemy and is released under
|
||||||
|
# the MIT License: https://www.opensource.org/licenses/mit-license.php
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
|
from .dml import Delete
|
||||||
|
from .dml import Insert
|
||||||
|
from .dml import Update
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ._typing import _DMLTableArgument
|
||||||
|
|
||||||
|
|
||||||
|
def insert(table: _DMLTableArgument) -> Insert:
|
||||||
|
"""Construct an :class:`_expression.Insert` object.
|
||||||
|
|
||||||
|
E.g.::
|
||||||
|
|
||||||
|
from sqlalchemy import insert
|
||||||
|
|
||||||
|
stmt = insert(user_table).values(name="username", fullname="Full Username")
|
||||||
|
|
||||||
|
Similar functionality is available via the
|
||||||
|
:meth:`_expression.TableClause.insert` method on
|
||||||
|
:class:`_schema.Table`.
|
||||||
|
|
||||||
|
.. seealso::
|
||||||
|
|
||||||
|
:ref:`tutorial_core_insert` - in the :ref:`unified_tutorial`
|
||||||
|
|
||||||
|
|
||||||
|
:param table: :class:`_expression.TableClause`
|
||||||
|
which is the subject of the
|
||||||
|
insert.
|
||||||
|
|
||||||
|
:param values: collection of values to be inserted; see
|
||||||
|
:meth:`_expression.Insert.values`
|
||||||
|
for a description of allowed formats here.
|
||||||
|
Can be omitted entirely; a :class:`_expression.Insert` construct
|
||||||
|
will also dynamically render the VALUES clause at execution time
|
||||||
|
based on the parameters passed to :meth:`_engine.Connection.execute`.
|
||||||
|
|
||||||
|
:param inline: if True, no attempt will be made to retrieve the
|
||||||
|
SQL-generated default values to be provided within the statement;
|
||||||
|
in particular,
|
||||||
|
this allows SQL expressions to be rendered 'inline' within the
|
||||||
|
statement without the need to pre-execute them beforehand; for
|
||||||
|
backends that support "returning", this turns off the "implicit
|
||||||
|
returning" feature for the statement.
|
||||||
|
|
||||||
|
If both :paramref:`_expression.insert.values` and compile-time bind
|
||||||
|
parameters are present, the compile-time bind parameters override the
|
||||||
|
information specified within :paramref:`_expression.insert.values` on a
|
||||||
|
per-key basis.
|
||||||
|
|
||||||
|
The keys within :paramref:`_expression.Insert.values` can be either
|
||||||
|
:class:`~sqlalchemy.schema.Column` objects or their string
|
||||||
|
identifiers. Each key may reference one of:
|
||||||
|
|
||||||
|
* a literal data value (i.e. string, number, etc.);
|
||||||
|
* a Column object;
|
||||||
|
* a SELECT statement.
|
||||||
|
|
||||||
|
If a ``SELECT`` statement is specified which references this
|
||||||
|
``INSERT`` statement's table, the statement will be correlated
|
||||||
|
against the ``INSERT`` statement.
|
||||||
|
|
||||||
|
.. seealso::
|
||||||
|
|
||||||
|
:ref:`tutorial_core_insert` - in the :ref:`unified_tutorial`
|
||||||
|
|
||||||
|
""" # noqa: E501
|
||||||
|
return Insert(table)
|
||||||
|
|
||||||
|
|
||||||
|
def update(table: _DMLTableArgument) -> Update:
|
||||||
|
r"""Construct an :class:`_expression.Update` object.
|
||||||
|
|
||||||
|
E.g.::
|
||||||
|
|
||||||
|
from sqlalchemy import update
|
||||||
|
|
||||||
|
stmt = (
|
||||||
|
update(user_table).where(user_table.c.id == 5).values(name="user #5")
|
||||||
|
)
|
||||||
|
|
||||||
|
Similar functionality is available via the
|
||||||
|
:meth:`_expression.TableClause.update` method on
|
||||||
|
:class:`_schema.Table`.
|
||||||
|
|
||||||
|
:param table: A :class:`_schema.Table`
|
||||||
|
object representing the database
|
||||||
|
table to be updated.
|
||||||
|
|
||||||
|
|
||||||
|
.. seealso::
|
||||||
|
|
||||||
|
:ref:`tutorial_core_update_delete` - in the :ref:`unified_tutorial`
|
||||||
|
|
||||||
|
|
||||||
|
""" # noqa: E501
|
||||||
|
return Update(table)
|
||||||
|
|
||||||
|
|
||||||
|
def delete(table: _DMLTableArgument) -> Delete:
|
||||||
|
r"""Construct :class:`_expression.Delete` object.
|
||||||
|
|
||||||
|
E.g.::
|
||||||
|
|
||||||
|
from sqlalchemy import delete
|
||||||
|
|
||||||
|
stmt = delete(user_table).where(user_table.c.id == 5)
|
||||||
|
|
||||||
|
Similar functionality is available via the
|
||||||
|
:meth:`_expression.TableClause.delete` method on
|
||||||
|
:class:`_schema.Table`.
|
||||||
|
|
||||||
|
:param table: The table to delete rows from.
|
||||||
|
|
||||||
|
.. seealso::
|
||||||
|
|
||||||
|
:ref:`tutorial_core_update_delete` - in the :ref:`unified_tutorial`
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
return Delete(table)
|
||||||
1872
venv/Lib/site-packages/sqlalchemy/sql/_elements_constructors.py
Normal file
1872
venv/Lib/site-packages/sqlalchemy/sql/_elements_constructors.py
Normal file
File diff suppressed because it is too large
Load Diff
19
venv/Lib/site-packages/sqlalchemy/sql/_orm_types.py
Normal file
19
venv/Lib/site-packages/sqlalchemy/sql/_orm_types.py
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
# sql/_orm_types.py
|
||||||
|
# Copyright (C) 2022-2026 the SQLAlchemy authors and contributors
|
||||||
|
# <see AUTHORS file>
|
||||||
|
#
|
||||||
|
# This module is part of SQLAlchemy and is released under
|
||||||
|
# the MIT License: https://www.opensource.org/licenses/mit-license.php
|
||||||
|
|
||||||
|
"""ORM types that need to present specifically for **documentation only** of
|
||||||
|
the Executable.execution_options() method, which includes options that
|
||||||
|
are meaningful to the ORM.
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from ..util.typing import Literal
|
||||||
|
|
||||||
|
SynchronizeSessionArgument = Literal[False, "auto", "evaluate", "fetch"]
|
||||||
|
DMLStrategyArgument = Literal["bulk", "raw", "orm", "auto"]
|
||||||
75
venv/Lib/site-packages/sqlalchemy/sql/_py_util.py
Normal file
75
venv/Lib/site-packages/sqlalchemy/sql/_py_util.py
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
# sql/_py_util.py
|
||||||
|
# Copyright (C) 2005-2026 the SQLAlchemy authors and contributors
|
||||||
|
# <see AUTHORS file>
|
||||||
|
#
|
||||||
|
# This module is part of SQLAlchemy and is released under
|
||||||
|
# the MIT License: https://www.opensource.org/licenses/mit-license.php
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import typing
|
||||||
|
from typing import Any
|
||||||
|
from typing import Dict
|
||||||
|
from typing import Tuple
|
||||||
|
from typing import Union
|
||||||
|
|
||||||
|
from ..util.typing import Literal
|
||||||
|
|
||||||
|
if typing.TYPE_CHECKING:
|
||||||
|
from .cache_key import CacheConst
|
||||||
|
|
||||||
|
|
||||||
|
class prefix_anon_map(Dict[str, str]):
|
||||||
|
"""A map that creates new keys for missing key access.
|
||||||
|
|
||||||
|
Considers keys of the form "<ident> <name>" to produce
|
||||||
|
new symbols "<name>_<index>", where "index" is an incrementing integer
|
||||||
|
corresponding to <name>.
|
||||||
|
|
||||||
|
Inlines the approach taken by :class:`sqlalchemy.util.PopulateDict` which
|
||||||
|
is otherwise usually used for this type of operation.
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __missing__(self, key: str) -> str:
|
||||||
|
ident, derived = key.split(" ", 1)
|
||||||
|
anonymous_counter = self.get(derived, 1)
|
||||||
|
self[derived] = anonymous_counter + 1 # type: ignore
|
||||||
|
value = f"{derived}_{anonymous_counter}"
|
||||||
|
self[key] = value
|
||||||
|
return value
|
||||||
|
|
||||||
|
|
||||||
|
class cache_anon_map(
|
||||||
|
Dict[Union[int, "Literal[CacheConst.NO_CACHE]"], Union[Literal[True], str]]
|
||||||
|
):
|
||||||
|
"""A map that creates new keys for missing key access.
|
||||||
|
|
||||||
|
Produces an incrementing sequence given a series of unique keys.
|
||||||
|
|
||||||
|
This is similar to the compiler prefix_anon_map class although simpler.
|
||||||
|
|
||||||
|
Inlines the approach taken by :class:`sqlalchemy.util.PopulateDict` which
|
||||||
|
is otherwise usually used for this type of operation.
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
_index = 0
|
||||||
|
|
||||||
|
def get_anon(self, object_: Any) -> Tuple[str, bool]:
|
||||||
|
idself = id(object_)
|
||||||
|
if idself in self:
|
||||||
|
s_val = self[idself]
|
||||||
|
assert s_val is not True
|
||||||
|
return s_val, True
|
||||||
|
else:
|
||||||
|
# inline of __missing__
|
||||||
|
self[idself] = id_ = str(self._index)
|
||||||
|
self._index += 1
|
||||||
|
|
||||||
|
return id_, False
|
||||||
|
|
||||||
|
def __missing__(self, key: int) -> str:
|
||||||
|
self[key] = val = str(self._index)
|
||||||
|
self._index += 1
|
||||||
|
return val
|
||||||
Reference in New Issue
Block a user