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 :

Module « sqlalchemy.orm »

Classe « Query »

Informations générales

Héritage

builtins.object
    HasMemoized
        Generative
builtins.object
    SQLRole
        StatementRole
            Executable
        builtins.object
            HasHints
        builtins.object
            HasSuffixes
        builtins.object
            HasPrefixes
    builtins.object
        SupportsAnnotations
            SupportsCloneAnnotations
        builtins.object
            _SelectFromElements
                Query

Définition

class Query(_SelectFromElements, SupportsCloneAnnotations, HasPrefixes, HasSuffixes, HasHints, Executable):

Description [extrait de Query.__doc__]

ORM-level SQL construction object.

    :class:`_query.Query`
    is the source of all SELECT statements generated by the
    ORM, both those formulated by end-user query operations as well as by
    high level internal operations such as related collection loading.  It
    features a generative interface whereby successive calls return a new
    :class:`_query.Query` object, a copy of the former with additional
    criteria and options associated with it.

    :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.

    For a full walk through of :class:`_query.Query` usage, see the
    :ref:`ormtutorial_toplevel`.

    

Constructeur(s)

Signature du constructeur Description
__init__(self, entities, 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 0x7f40cb8a6380>
is_deleteFalse
is_dmlFalse
is_insertFalse
is_selectFalse
is_textFalse
is_updateFalse
load_optionsdefault_load_options(_legacy_uniquing=True)
logger<Logger sqlalchemy.orm.query.Query (WARNING)>
supports_executionTrue
uses_inspectionFalse

Liste des propriétés

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

Liste des opérateurs

Signature de l'opérateur Description
__getitem__(self, item)

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)
__iter__(self)
__str__(self)
add_column(self, column) Add a column expression to the list of result columns to be [extrait de add_column.__doc__]
add_columns(self, *column) Add one or more column expressions to the list [extrait de add_columns.__doc__]
add_entity(self, entity, alias=None) add a mapped entity to the list of result columns [extrait de add_entity.__doc__]
all(self) Return the results represented by this :class:`_query.Query` [extrait de all.__doc__]
apply_labels(self)
as_scalar(self) Return the full SELECT statement represented by this [extrait de as_scalar.__doc__]
autoflush(self, setting) Return a Query with a specific 'autoflush' setting. [extrait de autoflush.__doc__]
correlate(self, *fromclauses) Return a :class:`.Query` construct which will correlate the given [extrait de correlate.__doc__]
count(self) Return a count of rows this the SQL formed by this :class:`Query` [extrait de count.__doc__]
cte(self, name=None, recursive=False, nesting=False) Return the full SELECT statement represented by this [extrait de cte.__doc__]
delete(self, synchronize_session='evaluate') Perform a DELETE with an arbitrary WHERE clause. [extrait de delete.__doc__]
distinct(self, *expr) Apply a ``DISTINCT`` to the query and return the newly resulting [extrait de distinct.__doc__]
enable_assertions(self, value) Control whether assertions are generated. [extrait de enable_assertions.__doc__]
enable_eagerloads(self, value) Control whether or not eager joins and subqueries are [extrait de enable_eagerloads.__doc__]
except_(self, *q) Produce an EXCEPT of this Query against one or more queries. [extrait de except_.__doc__]
except_all(self, *q) Produce an EXCEPT ALL of this Query against one or more queries. [extrait de except_all.__doc__]
execution_options(self, **kwargs) Set non-SQL options which take effect during execution. [extrait de execution_options.__doc__]
exists(self) A convenience method that turns a query into an EXISTS subquery [extrait de exists.__doc__]
filter(self, *criterion) Apply the given filtering criterion to a copy [extrait de filter.__doc__]
filter_by(self, **kwargs) Apply the given filtering criterion to a copy [extrait de filter_by.__doc__]
first(self) Return the first result of this ``Query`` or [extrait de first.__doc__]
from_self(self, *entities) return a Query that selects from this Query's [extrait de from_self.__doc__]
from_statement(self, statement) Execute the given SELECT statement and return results. [extrait de from_statement.__doc__]
get(self, ident) Return an instance based on the given primary key identifier, [extrait de get.__doc__]
get_execution_options(self) Get the non-SQL options which will take effect during execution. [extrait de get_execution_options.__doc__]
group_by(self, *clauses) Apply one or more GROUP BY criterion to the query and return [extrait de group_by.__doc__]
having(self, criterion) Apply a HAVING criterion to the query and return the [extrait de having.__doc__]
instances(self, result_proxy, context=None) Return an ORM result given a :class:`_engine.CursorResult` and [extrait de instances.__doc__]
intersect(self, *q) Produce an INTERSECT of this Query against one or more queries. [extrait de intersect.__doc__]
intersect_all(self, *q) Produce an INTERSECT ALL of this Query against one or more queries. [extrait de intersect_all.__doc__]
join(self, target, *props, **kwargs) Create a SQL JOIN against this :class:`_query.Query` [extrait de join.__doc__]
label(self, name) Return the full SELECT statement represented by this [extrait de label.__doc__]
limit(self, limit) Apply a ``LIMIT`` to the query and return the newly resulting [extrait de limit.__doc__]
merge_result(self, iterator, load=True) Merge a result into this :class:`_query.Query` object's Session. [extrait de merge_result.__doc__]
offset(self, offset) Apply an ``OFFSET`` to the query and return the newly resulting [extrait de offset.__doc__]
one(self) Return exactly one result or raise an exception. [extrait de one.__doc__]
one_or_none(self) Return at most one result or raise an exception. [extrait de one_or_none.__doc__]
only_return_tuples(self, value) When set to True, the query results will always be a tuple. [extrait de only_return_tuples.__doc__]
options(self, *args) Return a new :class:`_query.Query` object, [extrait de options.__doc__]
order_by(self, *clauses) Apply one or more ORDER BY criterion to the query and return [extrait de order_by.__doc__]
outerjoin(self, target, *props, **kwargs) Create a left outer join against this ``Query`` object's criterion [extrait de outerjoin.__doc__]
params(self, *args, **kwargs) Add values for bind parameters which may have been [extrait de params.__doc__]
populate_existing(self) Return a :class:`_query.Query` [extrait de populate_existing.__doc__]
reset_joinpoint(self) Return a new :class:`.Query`, where the "join point" has [extrait de reset_joinpoint.__doc__]
scalar(self) Return the first element of the first result or None [extrait de scalar.__doc__]
scalar_subquery(self) Return the full SELECT statement represented by this [extrait de scalar_subquery.__doc__]
select_entity_from(self, from_obj) Set the FROM clause of this :class:`_query.Query` to a [extrait de select_entity_from.__doc__]
select_from(self, *from_obj) Set the FROM clause of this :class:`.Query` explicitly. [extrait de select_from.__doc__]
set_label_style(self, style) Apply column labels to the return value of Query.statement. [extrait de set_label_style.__doc__]
slice(self, start, stop) Computes the "slice" of the :class:`_query.Query` represented by [extrait de slice.__doc__]
subquery(self, name=None, with_labels=False, reduce_columns=False) Return the full SELECT statement represented by [extrait de subquery.__doc__]
union(self, *q) Produce a UNION of this Query against one or more queries. [extrait de union.__doc__]
union_all(self, *q) Produce a UNION ALL of this Query against one or more queries. [extrait de union_all.__doc__]
update(self, values, synchronize_session='evaluate', update_args=None) Perform an UPDATE with an arbitrary WHERE clause. [extrait de update.__doc__]
value(self, column) Return a scalar result corresponding to the given [extrait de value.__doc__]
values(self, *columns) Return an iterator yielding result tuples corresponding [extrait de values.__doc__]
where(self, *criterion) A synonym for :meth:`.Query.filter`. [extrait de where.__doc__]
with_entities(self, *entities) Return a new :class:`_query.Query` [extrait de with_entities.__doc__]
with_for_update(self, read=False, nowait=False, of=None, skip_locked=False, key_share=False) return a new :class:`_query.Query` [extrait de with_for_update.__doc__]
with_labels(self)
with_parent(self, instance, property=None, from_entity=None) Add filtering criterion that relates the given instance [extrait de with_parent.__doc__]
with_polymorphic(self, cls_or_mappers, selectable=None, polymorphic_on=None) Load columns for inheriting classes. [extrait de with_polymorphic.__doc__]
with_session(self, session) Return a :class:`_query.Query` that will use the given [extrait de with_session.__doc__]
with_transformation(self, fn) Return a new :class:`_query.Query` object transformed by [extrait de with_transformation.__doc__]
yield_per(self, count) Yield only ``count`` rows at a time. [extrait de yield_per.__doc__]

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

__init_subclass__, __subclasshook__, execute

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 object

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