class documentation

class ShardedQuery(Query):

View In Hierarchy

Undocumented

Method set​_shard Return a new query, limited to a single shard ID.
Method __init__ Construct a _query.Query directly.
Instance Variable ​_shard​_id Undocumented
Instance Variable execute​_chooser Undocumented
Instance Variable id​_chooser Undocumented
Instance Variable query​_chooser Undocumented

Inherited from Query:

Method __clause​_element__ Undocumented
Method __getitem__ Undocumented
Method __iter__ Undocumented
Method __str__ Undocumented
Method ​_clone Undocumented
Method ​_compile​_context Undocumented
Method ​_compile​_state Create an out-of-compiler ORMCompileState object.
Method ​_entity​_from​_pre​_ent​_zero Undocumented
Method ​_filter​_by​_zero for the filter_by() method, return the target entity for which we will attempt to derive an expression from based on string name.
Method ​_final​_statement Return the 'final' SELECT statement for this .Query.
Method ​_from​_selectable Undocumented
Method ​_from​_self Undocumented
Method ​_get​_bind​_args Undocumented
Method ​_get​_condition Undocumented
Method ​_get​_existing​_condition Undocumented
Method ​_get​_impl Undocumented
Method ​_get​_options Undocumented
Method ​_iter Undocumented
Method ​_next​_aliased​_generation Undocumented
Method ​_no​_clauseelement​_condition Undocumented
Method ​_no​_criterion​_assertion Undocumented
Method ​_no​_criterion​_condition Undocumented
Method ​_no​_limit​_offset Undocumented
Method ​_no​_statement​_condition Undocumented
Method ​_only​_full​_mapper​_zero Undocumented
Method ​_set​_enable​_single​_crit Undocumented
Method ​_set​_entities Undocumented
Method ​_set​_lazyload​_from Undocumented
Method ​_set​_op Undocumented
Method ​_set​_propagate​_attrs Undocumented
Method ​_set​_select​_from Undocumented
Method ​_statement​_20 Undocumented
Method ​_with​_compile​_options Undocumented
Method ​_with​_current​_path indicate that this query applies to objects loaded within a certain path.
Method ​_with​_invoke​_all​_eagers Set the 'invoke all eagers' flag which causes joined- and subquery loaders to traverse into already-loaded related objects and collections.
Method add​_column Add a column expression to the list of result columns to be returned.
Method add​_columns Add one or more column expressions to the list of result columns to be returned.
Method add​_entity add a mapped entity to the list of result columns to be returned.
Method all Return the results represented by this _query.Query as a list.
Method as​_scalar Return the full SELECT statement represented by this _query.Query, converted to a scalar subquery.
Method autoflush Return a Query with a specific 'autoflush' setting.
Method correlate Return a .Query construct which will correlate the given FROM clauses to that of an enclosing .Query or ~.expression.select.
Method count Return a count of rows this the SQL formed by this Query would return.
Method cte Return the full SELECT statement represented by this _query.Query represented as a common table expression (CTE).
Method delete Perform a DELETE with an arbitrary WHERE clause.
Method distinct Apply a DISTINCT to the query and return the newly resulting Query.
Method enable​_assertions Control whether assertions are generated.
Method enable​_eagerloads Control whether or not eager joins and subqueries are rendered.
Method except​_ Produce an EXCEPT of this Query against one or more queries.
Method except​_all Produce an EXCEPT ALL of this Query against one or more queries.
Method execution​_options Set non-SQL options which take effect during execution.
Method exists A convenience method that turns a query into an EXISTS subquery of the form EXISTS (SELECT 1 FROM ... WHERE ...).
Method filter Apply the given filtering criterion to a copy of this _query.Query, using SQL expressions.
Method filter​_by Apply the given filtering criterion to a copy of this _query.Query, using keyword expressions.
Method first Return the first result of this Query or None if the result doesn't contain any row.
Method from​_self return a Query that selects from this Query's SELECT statement.
Method from​_statement Execute the given SELECT statement and return results.
Method get Return an instance based on the given primary key identifier, or None if not found.
Method get​_execution​_options Get the non-SQL options which will take effect during execution.
Method group​_by Apply one or more GROUP BY criterion to the query and return the newly resulting _query.Query.
Method having Apply a HAVING criterion to the query and return the newly resulting _query.Query.
Method instances Return an ORM result given a _engine.CursorResult and .QueryContext.
Method intersect Produce an INTERSECT of this Query against one or more queries.
Method intersect​_all Produce an INTERSECT ALL of this Query against one or more queries.
Method join No summary
Method label Return the full SELECT statement represented by this _query.Query, converted to a scalar subquery with a label of the given name.
Method limit Apply a LIMIT to the query and return the newly resulting Query.
Method merge​_result Merge a result into this _query.Query object's Session.
Method offset Apply an OFFSET to the query and return the newly resulting Query.
Method one Return exactly one result or raise an exception.
Method one​_or​_none Return at most one result or raise an exception.
Method only​_return​_tuples When set to True, the query results will always be a tuple.
Method options Return a new _query.Query object, applying the given list of mapper options.
Method order​_by Apply one or more ORDER BY criteria to the query and return the newly resulting _query.Query.
Method outerjoin Create a left outer join against this Query object's criterion and apply generatively, returning the newly resulting Query.
Method params Add values for bind parameters which may have been specified in filter().
Method populate​_existing Return a _query.Query that will expire and refresh all instances as they are loaded, or reused from the current .Session.
Method reset​_joinpoint Return a new .Query, where the "join point" has been reset back to the base FROM entities of the query.
Method scalar Return the first element of the first result or None if no rows present. If multiple rows are returned, raises MultipleResultsFound.
Method scalar​_subquery Return the full SELECT statement represented by this _query.Query, converted to a scalar subquery.
Method select​_entity​_from Set the FROM clause of this _query.Query to a core selectable, applying it as a replacement FROM clause for corresponding mapped entities.
Method select​_from Set the FROM clause of this .Query explicitly.
Method set​_label​_style Apply column labels to the return value of Query.statement.
Method slice Computes the "slice" of the _query.Query represented by the given indices and returns the resulting _query.Query.
Method subquery Return the full SELECT statement represented by this _query.Query, embedded within an _expression.Alias.
Method union Produce a UNION of this Query against one or more queries.
Method union​_all Produce a UNION ALL of this Query against one or more queries.
Method update Perform an UPDATE with an arbitrary WHERE clause.
Method value Return a scalar result corresponding to the given column expression.
Method values Return an iterator yielding result tuples corresponding to the given list of columns
Method where A synonym for .Query.filter.
Method with​_entities Return a new _query.Query replacing the SELECT list with the given entities.
Method with​_for​_update return a new _query.Query with the specified options for the FOR UPDATE clause.
Method with​_labels Undocumented
Method with​_parent No summary
Method with​_polymorphic Load columns for inheriting classes.
Method with​_session Return a _query.Query that will use the given .Session.
Method with​_transformation Return a new _query.Query object transformed by the given function.
Method yield​_per Yield only count rows at a time.
Class Variable ​_having​_criteria Undocumented
Class Variable ​_memoized​_select​_entities Undocumented
Class Variable ​_setup​_joins Undocumented
Class Variable load​_options Undocumented
Instance Variable ​_aliased​_generation Undocumented
Instance Variable ​_aliased​_generation​_counter Undocumented
Instance Variable ​_auto​_correlate Undocumented
Instance Variable ​_compile​_options Undocumented
Instance Variable ​_correlate Undocumented
Instance Variable ​_distinct Undocumented
Instance Variable ​_distinct​_on Undocumented
Instance Variable ​_enable​_assertions Undocumented
Instance Variable ​_execution​_options Undocumented
Instance Variable ​_for​_update​_arg Undocumented
Instance Variable ​_from​_obj Undocumented
Instance Variable ​_group​_by​_clauses Undocumented
Instance Variable ​_label​_style Undocumented
Instance Variable ​_last​_joined​_entity Undocumented
Instance Variable ​_legacy​_setup​_joins Undocumented
Instance Variable ​_limit​_clause Undocumented
Instance Variable ​_offset​_clause Undocumented
Instance Variable ​_order​_by​_clauses Undocumented
Instance Variable ​_params Undocumented
Instance Variable ​_propagate​_attrs Undocumented
Instance Variable ​_raw​_columns Undocumented
Instance Variable ​_statement Undocumented
Instance Variable ​_where​_criteria Undocumented
Instance Variable session Undocumented
Property ​_current​_path Undocumented
Property ​_has​_row​_limiting​_clause Undocumented
Property column​_descriptions Return metadata about the columns which would be returned by this _query.Query.
Property get​_label​_style Retrieve the current label style.
Property is​_single​_entity Indicates if this _query.Query returns tuples or single entities.
Property lazy​_loaded​_from An .InstanceState that is using this _query.Query for a lazy load operation.
Property selectable Return the _expression.Select object emitted by this _query.Query.
Property statement The full SELECT statement represented by this Query.
Property whereclause A readonly attribute which returns the current WHERE criterion for this Query.

Inherited from _SelectFromElements (via Query):

Method ​_iterate​_from​_elements Undocumented

Inherited from SupportsCloneAnnotations (via Query):

Method ​_annotate return a copy of this ClauseElement with annotations updated by the given dictionary.
Method ​_deannotate return a copy of this _expression.ClauseElement with annotations removed.
Method ​_with​_annotations return a copy of this ClauseElement with annotations replaced by the given dictionary.
Class Variable ​_clone​_annotations​_traverse​_internals Undocumented

Inherited from SupportsAnnotations (via Query, SupportsCloneAnnotations):

Property ​_annotations​_cache​_key Undocumented

Inherited from HasPrefixes (via Query):

Method ​_setup​_prefixes Undocumented
Method prefix​_with Add one or more expressions following the statement keyword, i.e. SELECT, INSERT, UPDATE, or DELETE. Generative.
Class Variable ​_has​_prefixes​_traverse​_internals Undocumented
Instance Variable ​_prefixes Undocumented

Inherited from HasSuffixes (via Query):

Method ​_setup​_suffixes Undocumented
Method suffix​_with Add one or more expressions following the statement as a whole.
Class Variable ​_has​_suffixes​_traverse​_internals Undocumented
Instance Variable ​_suffixes Undocumented

Inherited from HasHints (via Query):

Method with​_hint Add an indexing or other executional context hint for the given selectable to this _expression.Select or other selectable object.
Method with​_statement​_hint Add a statement hint to this _expression.Select or other selectable object.
Class Variable ​_has​_hints​_traverse​_internals Undocumented
Class Variable ​_hints Undocumented
Class Variable ​_statement​_hints Undocumented

Inherited from Executable (via Query):

Method ​_add​_context​_option Add a context option to this statement.
Method ​_set​_compile​_options Assign the compile options to a new value.
Method ​_update​_compile​_options update the _compile_options with new keys.
Method execute Compile and execute this .Executable.
Class Variable ​_bind Undocumented
Class Variable ​_executable​_traverse​_internals Undocumented
Class Variable ​_with​_context​_options Undocumented
Class Variable ​_with​_options Undocumented
Class Variable is​_delete Undocumented
Class Variable is​_dml Undocumented
Class Variable is​_insert Undocumented
Class Variable is​_select Undocumented
Class Variable is​_text Undocumented
Class Variable is​_update Undocumented
Class Variable supports​_execution Undocumented
Property ​_effective​_plugin​_target Undocumented
Property bind Returns the _engine.Engine or _engine.Connection to which this .Executable is bound, or None if none found.

Inherited from StatementRole (via Query, Executable):

Class Variable ​_role​_name Undocumented

Inherited from SQLRole (via Query, Executable, StatementRole):

Class Variable allows​_lambda Undocumented
Class Variable uses​_inspection Undocumented

Inherited from Generative (via Query, Executable):

Method ​_generate Undocumented
def set_shard(self, shard_id):

Return a new query, limited to a single shard ID.

All subsequent operations with the returned query will be against the single shard regardless of other state.

The shard_id can be passed for a 2.0 style execution to the bind_arguments dictionary of .Session.execute:

results = session.execute(
    stmt,
    bind_arguments={"shard_id": "my_shard"}
)
def __init__(self, *args, **kwargs):

Construct a _query.Query directly.

E.g.:

q = Query([User, Address], session=some_session)

The above is equivalent to:

q = some_session.query(User, Address)

See Also

.Session.query

_query.Query.with_session

Parameters
*argsUndocumented
**kwargsUndocumented
entitiesa sequence of entities and/or SQL expressions.
sessiona .Session with which the _query.Query will be associated. Optional; a _query.Query can be associated with a .Session generatively via the _query.Query.with_session method as well.
_shard_id =

Undocumented

execute_chooser =

Undocumented

id_chooser =

Undocumented

query_chooser =

Undocumented