Participer au site avec un Tip
Rechercher
 

Améliorations / Corrections

Vous avez des améliorations (ou des corrections) à proposer pour ce document : je vous remerçie par avance de m'en faire part, cela m'aide à améliorer le site.

Emplacement :

Description des améliorations :

Vous êtes un professionnel et vous avez besoin d'une formation ? Mise en oeuvre d'IHM
avec Qt et PySide6
Voir le programme détaillé
Module « sqlalchemy.orm »

Classe « Query »

Informations générales

Héritage

                builtins.object
                    Generic
        builtins.object
            SQLRole
                StatementRole
                    Executable
            builtins.object
                HasMemoized
                    Generative
                builtins.object
                    Identified
                builtins.object
                    EventTarget
                builtins.object
                    HasHints
                builtins.object
                    HasSuffixes
                builtins.object
                    HasPrefixes
builtins.object
    Visitable
builtins.object
    HasTraverseInternals
        ExternallyTraversible
            SupportsAnnotations
                SupportsWrappingAnnotations
                    SupportsCloneAnnotations
                builtins.object
                    _SelectFromElements
                        Query

Définition

class Query(_SelectFromElements, SupportsCloneAnnotations, HasPrefixes, HasSuffixes, HasHints, EventTarget, Identified, Generative, Executable, Generic):

help(Query)

ORM-level SQL construction object.

.. legacy:: The ORM :class:`.Query` object is a legacy construct
   as of SQLAlchemy 2.0.   See the notes at the top of
   :ref:`query_api_toplevel` for an overview, including links to migration
   documentation.

:class:`_query.Query` objects are normally initially generated using the
:meth:`~.Session.query` method of :class:`.Session`, and in
less common cases by instantiating the :class:`_query.Query` directly and
associating with a :class:`.Session` using the
:meth:`_query.Query.with_session`
method.

Constructeur(s)

Signature du constructeur Description
__init__(self, entities: 'Union[_ColumnsClauseArgument[Any], Sequence[_ColumnsClauseArgument[Any]]]', session: 'Optional[Session]' = None) Construct a :class:`_query.Query` directly. [extrait de __init__.__doc__]

Liste des attributs statiques

Nom de l'attribut Valeur
allows_lambdaFalse
dispatch<sqlalchemy.event.base.QueryEventsDispatch object at 0x0000020DA14CD250>
is_deleteFalse
is_dmlFalse
is_from_statementFalse
is_insertFalse
is_selectFalse
is_textFalse
is_updateFalse
load_optionsdefault_load_options(_legacy_uniquing=True)
logger<Logger sqlalchemy.orm.query.Query (WARNING)>
logging_nameNone
supports_executionTrue
uses_inspectionFalse

Liste des propriétés

Nom de la propriétéDescription
column_descriptionsReturn metadata about the columns which would be [extrait de column_descriptions.__doc__]
get_label_style
is_single_entityIndicates if this :class:`_query.Query` [extrait de is_single_entity.__doc__]
lazy_loaded_fromAn :class:`.InstanceState` that is using this :class:`_query.Query` [extrait de lazy_loaded_from.__doc__]
selectableReturn the :class:`_expression.Select` object emitted by this [extrait de selectable.__doc__]
statementThe full SELECT statement represented by this Query. [extrait de statement.__doc__]
whereclauseA readonly attribute which returns the current WHERE criterion for [extrait de whereclause.__doc__]

Liste des opérateurs

Signature de l'opérateur Description
__getitem__(self, item: 'Any') -> 'Any'

Opérateurs hérités de la classe object

__eq__, __ge__, __gt__, __le__, __lt__, __ne__

Liste des méthodes

Toutes les méthodes Méthodes d'instance Méthodes statiques Méthodes dépréciées
Signature de la méthodeDescription
__clause_element__(self) -> 'Union[Select[_T], FromStatement[_T]]'
__iter__(self) -> 'Iterator[_T]'
__str__(self) -> 'str'
add_column(self, column: '_ColumnExpressionArgument[Any]') -> 'Query[Any]' Add a column expression to the list of result columns to be [extrait de add_column.__doc__]
add_columns(self, *column: '_ColumnExpressionArgument[Any]') -> 'Query[Any]' Add one or more column expressions to the list [extrait de add_columns.__doc__]
add_entity(self, entity: '_EntityType[Any]', alias: 'Optional[Union[Alias, Subquery]]' = None) -> 'Query[Any]' add a mapped entity to the list of result columns [extrait de add_entity.__doc__]
all(self) -> 'List[_T]' Return the results represented by this :class:`_query.Query` [extrait de all.__doc__]
apply_labels(self) -> 'Self'
as_scalar(self) -> 'ScalarSelect[Any]' Return the full SELECT statement represented by this [extrait de as_scalar.__doc__]
autoflush(self, setting: 'bool') -> 'Self' Return a Query with a specific 'autoflush' setting. [extrait de autoflush.__doc__]
correlate(self, *fromclauses: 'Union[Literal[None, False], _FromClauseArgument]') -> 'Self' Return a :class:`.Query` construct which will correlate the given [extrait de correlate.__doc__]
count(self) -> 'int' Return a count of rows this the SQL formed by this :class:`Query` [extrait de count.__doc__]
cte(self, name: 'Optional[str]' = None, recursive: 'bool' = False, nesting: 'bool' = False) -> 'CTE' Return the full SELECT statement represented by this [extrait de cte.__doc__]
delete(self, synchronize_session: 'SynchronizeSessionArgument' = 'auto', delete_args: 'Optional[Dict[Any, Any]]' = None) -> 'int' Perform a DELETE with an arbitrary WHERE clause. [extrait de delete.__doc__]
distinct(self, *expr: '_ColumnExpressionArgument[Any]') -> 'Self' Apply a ``DISTINCT`` to the query and return the newly resulting [extrait de distinct.__doc__]
enable_assertions(self, value: 'bool') -> 'Self' Control whether assertions are generated. [extrait de enable_assertions.__doc__]
enable_eagerloads(self, value: 'bool') -> 'Self' Control whether or not eager joins and subqueries are [extrait de enable_eagerloads.__doc__]
except_(self, *q: 'Query[Any]') -> 'Self' Produce an EXCEPT of this Query against one or more queries. [extrait de except_.__doc__]
except_all(self, *q: 'Query[Any]') -> 'Self' Produce an EXCEPT ALL of this Query against one or more queries. [extrait de except_all.__doc__]
execution_options(self, **kwargs: 'Any') -> 'Self' Set non-SQL options which take effect during execution. [extrait de execution_options.__doc__]
exists(self) -> 'Exists' A convenience method that turns a query into an EXISTS subquery [extrait de exists.__doc__]
filter(self, *criterion: '_ColumnExpressionArgument[bool]') -> 'Self' Apply the given filtering criterion to a copy [extrait de filter.__doc__]
filter_by(self, **kwargs: 'Any') -> 'Self' Apply the given filtering criterion to a copy [extrait de filter_by.__doc__]
first(self) -> 'Optional[_T]' Return the first result of this ``Query`` or [extrait de first.__doc__]
from_statement(self, statement: 'ExecutableReturnsRows') -> 'Self' Execute the given SELECT statement and return results. [extrait de from_statement.__doc__]
get(self, ident: '_PKIdentityArgument') -> 'Optional[Any]' Return an instance based on the given primary key identifier, [extrait de get.__doc__]
get_execution_options(self) -> '_ImmutableExecuteOptions' Get the non-SQL options which will take effect during execution. [extrait de get_execution_options.__doc__]
group_by(self, _Query__first: 'Union[Literal[None, False, _NoArg.NO_ARG], _ColumnExpressionOrStrLabelArgument[Any]]' = _NoArg.NO_ARG, *clauses: '_ColumnExpressionOrStrLabelArgument[Any]') -> 'Self' Apply one or more GROUP BY criterion to the query and return [extrait de group_by.__doc__]
having(self, *having: '_ColumnExpressionArgument[bool]') -> 'Self' Apply a HAVING criterion to the query and return the [extrait de having.__doc__]
instances(self, result_proxy: 'CursorResult[Any]', context: 'Optional[QueryContext]' = None) -> 'Any' Return an ORM result given a :class:`_engine.CursorResult` and [extrait de instances.__doc__]
intersect(self, *q: 'Query[Any]') -> 'Self' Produce an INTERSECT of this Query against one or more queries. [extrait de intersect.__doc__]
intersect_all(self, *q: 'Query[Any]') -> 'Self' Produce an INTERSECT ALL of this Query against one or more queries. [extrait de intersect_all.__doc__]
join(self, target: '_JoinTargetArgument', onclause: 'Optional[_OnClauseArgument]' = None, *, isouter: 'bool' = False, full: 'bool' = False) -> 'Self' Create a SQL JOIN against this :class:`_query.Query` [extrait de join.__doc__]
label(self, name: 'Optional[str]') -> 'Label[Any]' Return the full SELECT statement represented by this [extrait de label.__doc__]
limit(self, limit: '_LimitOffsetType') -> 'Self' Apply a ``LIMIT`` to the query and return the newly resulting [extrait de limit.__doc__]
merge_result(self, iterator: 'Union[FrozenResult[Any], Iterable[Sequence[Any]], Iterable[object]]', load: 'bool' = True) -> 'Union[FrozenResult[Any], Iterable[Any]]' Merge a result into this :class:`_query.Query` object's Session. [extrait de merge_result.__doc__]
offset(self, offset: '_LimitOffsetType') -> 'Self' Apply an ``OFFSET`` to the query and return the newly resulting [extrait de offset.__doc__]
one(self) -> '_T' Return exactly one result or raise an exception. [extrait de one.__doc__]
one_or_none(self) -> 'Optional[_T]' Return at most one result or raise an exception. [extrait de one_or_none.__doc__]
only_return_tuples(self, value: 'bool') -> 'Query[Any]' When set to True, the query results will always be a [extrait de only_return_tuples.__doc__]
options(self, *args: 'ExecutableOption') -> 'Self' Return a new :class:`_query.Query` object, [extrait de options.__doc__]
order_by(self, _Query__first: 'Union[Literal[None, False, _NoArg.NO_ARG], _ColumnExpressionOrStrLabelArgument[Any]]' = _NoArg.NO_ARG, *clauses: '_ColumnExpressionOrStrLabelArgument[Any]') -> 'Self' Apply one or more ORDER BY criteria to the query and return [extrait de order_by.__doc__]
outerjoin(self, target: '_JoinTargetArgument', onclause: 'Optional[_OnClauseArgument]' = None, *, full: 'bool' = False) -> 'Self' Create a left outer join against this ``Query`` object's criterion [extrait de outerjoin.__doc__]
params(self, _Query__params: 'Optional[Dict[str, Any]]' = None, **kw: 'Any') -> 'Self' Add values for bind parameters which may have been [extrait de params.__doc__]
populate_existing(self) -> 'Self' Return a :class:`_query.Query` [extrait de populate_existing.__doc__]
reset_joinpoint(self) -> 'Self' Return a new :class:`.Query`, where the "join point" has [extrait de reset_joinpoint.__doc__]
scalar(self) -> 'Any' Return the first element of the first result or None [extrait de scalar.__doc__]
scalar_subquery(self) -> 'ScalarSelect[Any]' Return the full SELECT statement represented by this [extrait de scalar_subquery.__doc__]
select_from(self, *from_obj: '_FromClauseArgument') -> 'Self' Set the FROM clause of this :class:`.Query` explicitly. [extrait de select_from.__doc__]
set_label_style(self, style: 'SelectLabelStyle') -> 'Self' Apply column labels to the return value of Query.statement. [extrait de set_label_style.__doc__]
slice(self, start: 'int', stop: 'int') -> 'Self' Computes the "slice" of the :class:`_query.Query` represented by [extrait de slice.__doc__]
subquery(self, name: 'Optional[str]' = None, with_labels: 'bool' = False, reduce_columns: 'bool' = False) -> 'Subquery' Return the full SELECT statement represented by [extrait de subquery.__doc__]
tuples(self: 'Query[_O]') -> 'Query[Tuple[_O]]' return a tuple-typed form of this :class:`.Query`. [extrait de tuples.__doc__]
union(self, *q: 'Query[Any]') -> 'Self' Produce a UNION of this Query against one or more queries. [extrait de union.__doc__]
union_all(self, *q: 'Query[Any]') -> 'Self' Produce a UNION ALL of this Query against one or more queries. [extrait de union_all.__doc__]
update(self, values: 'Dict[_DMLColumnArgument, Any]', synchronize_session: 'SynchronizeSessionArgument' = 'auto', update_args: 'Optional[Dict[Any, Any]]' = None) -> 'int' Perform an UPDATE with an arbitrary WHERE clause. [extrait de update.__doc__]
value(self, column: '_ColumnExpressionArgument[Any]') -> 'Any' Return a scalar result corresponding to the given [extrait de value.__doc__]
values(self, *columns: '_ColumnsClauseArgument[Any]') -> 'Iterable[Any]' Return an iterator yielding result tuples corresponding [extrait de values.__doc__]
where(self, *criterion: '_ColumnExpressionArgument[bool]') -> 'Self' A synonym for :meth:`.Query.filter`. [extrait de where.__doc__]
with_entities(self, *entities: '_ColumnsClauseArgument[Any]', **_Query__kw: 'Any') -> 'Query[Any]' Return a new :class:`_query.Query` [extrait de with_entities.__doc__]
with_for_update(self, *, nowait: 'bool' = False, read: 'bool' = False, of: 'Optional[_ForUpdateOfArgument]' = None, skip_locked: 'bool' = False, key_share: 'bool' = False) -> 'Self' return a new :class:`_query.Query` [extrait de with_for_update.__doc__]
with_labels(self) -> 'Self'
with_parent(self, instance: 'object', property: 'Optional[attributes.QueryableAttribute[Any]]' = None, from_entity: 'Optional[_ExternalEntityType[Any]]' = None) -> 'Self' Add filtering criterion that relates the given instance [extrait de with_parent.__doc__]
with_session(self, session: 'Session') -> 'Self' Return a :class:`_query.Query` that will use the given [extrait de with_session.__doc__]
with_transformation(self, fn: 'Callable[[Query[Any]], Query[Any]]') -> 'Query[Any]' Return a new :class:`_query.Query` object transformed by [extrait de with_transformation.__doc__]
yield_per(self, count: 'int') -> 'Self' Yield only ``count`` rows at a time. [extrait de yield_per.__doc__]

Méthodes héritées de la classe Generic

__class_getitem__, __init_subclass__, __subclasshook__

Méthodes héritées de la classe Executable

__init_subclass__, __subclasshook__

Méthodes héritées de la classe HasMemoized

memoized_attribute, memoized_instancemethod

Méthodes héritées de la classe HasHints

with_hint, with_statement_hint

Méthodes héritées de la classe HasSuffixes

suffix_with

Méthodes héritées de la classe HasPrefixes

prefix_with

Méthodes héritées de la classe Visitable

__class_getitem__

Méthodes héritées de la classe HasTraverseInternals

get_children

Méthodes héritées de la classe object

__delattr__, __dir__, __format__, __getattribute__, __getstate__, __hash__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__

Vous êtes un professionnel et vous avez besoin d'une formation ? Programmation Python
Les compléments
Voir le programme détaillé