THE ORIONIS API
Build with clarity.
Explore the building blocks of an async-first Python framework. Every module, class, and method — connected, searchable, and ready to build with.
class IQueryBuilderBase(ABC): (source)
Known subclasses: orionis.orm.contracts.IModelQueryBuilder, orionis.orm.contracts.raw_builder.IRawQueryBuilder
Contract of the query language shared by every Orionis builder.
It declares the fluent clause surface (projection, conditions, joins, grouping, ordering, paging, locking, unions) and the terminals whose result does not depend on how rows are represented. Model-bound and model-less builders both honor it, which is what guarantees DB.table(...) and Model.query() speak the same language.
| Method | add |
Append columns to the current projection. |
| Async Method | avg |
Return the average value of a column among matching rows. |
| Method | clone |
Return an independent copy of this builder. |
| Async Method | count |
Count the rows matched by the query. |
| Method | cross |
Add a CROSS JOIN to the query. |
| Async Method | delete |
Delete the rows matched by the query. |
| Method | distinct |
Collapse duplicate rows from the query results. |
| Async Method | doesnt |
Report whether the query matches no rows. |
| Async Method | exists |
Report whether the query matches at least one row. |
| Method | for |
Limit the query to a single page of results. |
| Method | full |
Add a FULL OUTER JOIN to the query. |
| Method | group |
Add grouping columns to the query. |
| Method | having |
Add a post-grouping condition to the query. |
| Method | having |
Add a raw SQL post-grouping condition. |
| Async Method | insert |
Insert one or many rows into the target table. |
| Method | join |
Add an INNER JOIN to the query. |
| Method | join |
Join a subquery as a derived table with an INNER JOIN. |
| Method | latest |
Order the query by a timestamp column in descending order. |
| Method | left |
Add a LEFT OUTER JOIN to the query. |
| Method | left |
Join a subquery as a derived table with a LEFT OUTER JOIN. |
| Method | limit |
Limit the number of rows returned by the query. |
| Method | lock |
Lock the selected rows against concurrent writes. |
| Async Method | max |
Return the maximum value of a column among matching rows. |
| Async Method | min |
Return the minimum value of a column among matching rows. |
| Method | offset |
Skip the given number of rows before returning results. |
| Method | oldest |
Order the query by a timestamp column in ascending order. |
| Method | order |
Add an ordering rule to the query. |
| Method | or |
Add an OR-combined post-grouping condition to the query. |
| Method | or |
Add an OR-combined filtering condition. |
| Method | or |
Add an OR-combined comparison between two columns. |
| Method | or |
Add an OR-combined EXISTS condition. |
| Method | or |
Add an OR-combined set-membership condition. |
| Method | or |
Add an OR-combined NOT EXISTS condition. |
| Method | or |
Add an OR-combined set-exclusion condition. |
| Method | or |
Add an OR-combined IS NOT NULL condition. |
| Method | or |
Add an OR-combined IS NULL condition. |
| Method | or |
Add an OR-combined raw SQL condition. |
| Method | right |
Add a RIGHT OUTER JOIN to the query. |
| Method | right |
Join a subquery as a derived table with a RIGHT OUTER JOIN. |
| Method | select |
Restrict the query projection to the given columns. |
| Method | select |
Append a raw SQL fragment to the projection. |
| Method | select |
Append a scalar subquery to the projection under an alias. |
| Method | shared |
Lock the selected rows in shared mode. |
| Method | skip |
Skip the given number of rows; alias of offset. |
| Async Method | sum |
Return the sum of a column among matching rows. |
| Method | take |
Limit the number of rows returned; alias of limit. |
| Method | to |
Return the engine-agnostic plan assembled so far. |
| Method | union |
Append another query's rows, collapsing duplicates. |
| Method | union |
Append another query's rows, keeping duplicates. |
| Async Method | update |
Mass update the rows matched by the query. |
| Method | where |
Add an AND-combined filtering condition. |
| Method | where |
Filter rows whose column value lies between two boundaries. |
| Method | where |
Compare two columns of the query against each other. |
| Method | where |
Filter rows whose column value contains the given text. |
| Method | where |
Filter rows whose column value ends with the given text. |
| Method | where |
Keep rows for which a correlated subquery returns any row. |
| Method | where |
Filter rows matching a case-insensitive SQL LIKE pattern. |
| Method | where |
Filter rows whose column value belongs to the given set. |
| Method | where |
Filter rows whose column value matches an SQL LIKE pattern. |
| Method | where |
Filter rows whose column value lies outside two boundaries. |
| Method | where |
Keep rows for which a correlated subquery returns no row. |
| Method | where |
Filter rows not matching a case-insensitive LIKE pattern. |
| Method | where |
Filter rows whose column value is outside the given set. |
| Method | where |
Filter rows not matching an SQL LIKE pattern. |
| Method | where |
Filter rows whose column value is not NULL. |
| Method | where |
Filter rows whose column value is NULL. |
| Method | where |
Add an AND-combined raw SQL condition. |
| Method | where |
Filter rows whose column value matches a regular expression. |
| Method | where |
Filter rows whose column value starts with the given text. |
| Class Variable | __slots__ |
Undocumented |
Append columns to the current projection.
| Parameters | |
*columns:str | Column names to add to the projection. |
| Returns | |
IQueryBuilderBase | The same builder, enabling fluent chaining. |
orionis.orm.query.ModelQueryBuilder, orionis.orm.relations.BelongsToManyRelation, orionis.orm.relations.BelongsToManyRelationReturn an independent copy of this builder.
| Returns | |
IQueryBuilderBase | Detached copy carrying its own plan. |
Add a CROSS JOIN to the query.
| Parameters | |
table:str or TableDefinition | Table name to join, or its full definition. |
alias:str or None, optional | Alias the joined table is referred to by. |
| Returns | |
IQueryBuilderBase | The same builder, enabling fluent chaining. |
orionis.orm.query.ModelQueryBuilder, orionis.orm.relations.BelongsToManyRelation, orionis.orm.relations.BelongsToManyRelationDelete the rows matched by the query.
| Returns | |
int | Number of affected rows. |
Collapse duplicate rows from the query results.
| Returns | |
IQueryBuilderBase | The same builder, enabling fluent chaining. |
orionis.orm.relations.BelongsToManyRelation, orionis.orm.relations.BelongsToManyRelation, orionis.orm.relations.BelongsToManyRelationReport whether the query matches at least one row.
| Returns | |
bool | True when a matching row exists. |
Limit the query to a single page of results.
| Parameters | |
page:int | Page number starting at 1. |
perint, optional | Number of items per page. Defaults to 15. |
| Returns | |
IQueryBuilderBase | The same builder, enabling fluent chaining. |
str | TableDefinition, first: Any = None, operator: str | None = None, second: str | None = None, *, alias: str | None = None) -> Self:
(source)
¶
Add a FULL OUTER JOIN to the query.
| Parameters | |
table:str or TableDefinition | Table name to join, or its full definition. |
first:Any, optional | Left-hand column of the ON condition, or a join callable. |
operator:str or None, optional | Comparison operator relating both sides. |
second:str or None, optional | Right-hand column of the ON condition. |
alias:str or None, optional | Alias the joined table is referred to by. |
| Returns | |
IQueryBuilderBase | The same builder, enabling fluent chaining. |
Add grouping columns to the query.
| Parameters | |
*columns:str | Columns to group by. |
| Returns | |
IQueryBuilderBase | The same builder, enabling fluent chaining. |
Add a post-grouping condition to the query.
| Parameters | |
column:Any | Column name, mapping of equality pairs, or grouping callable. |
*args:Any | Either the bound value, or an operator followed by a value. |
| Returns | |
IQueryBuilderBase | The same builder, enabling fluent chaining. |
Add a raw SQL post-grouping condition.
| Parameters | |
sql:str | SQL fragment using named :param placeholders. |
bindings:dict or None, optional | Values bound to the placeholders of the fragment. |
| Returns | |
IQueryBuilderBase | The same builder, enabling fluent chaining. |
Insert one or many rows into the target table.
| Parameters | |
values:dict or list of dict | Column values for one row, or a list of rows. |
| Returns | |
InsertResult | Result carrying the generated key and affected row count. |
str | TableDefinition, first: Any = None, operator: str | None = None, second: str | None = None, *, alias: str | None = None) -> Self:
(source)
¶
Add an INNER JOIN to the query.
| Parameters | |
table:str or TableDefinition | Table name to join, or its full definition. |
first:Any, optional | Left-hand column of the ON condition, or a callable receiving a join clause to declare several conditions. |
operator:str or None, optional | Comparison operator relating both sides. |
second:str or None, optional | Right-hand column of the ON condition. |
alias:str or None, optional | Alias the joined table is referred to by. |
| Returns | |
IQueryBuilderBase | The same builder, enabling fluent chaining. |
Any, alias: str, first: Any = None, operator: str | None = None, second: str | None = None) -> Self:
(source)
¶
Join a subquery as a derived table with an INNER JOIN.
| Parameters | |
query:Any | Subquery source producing the derived table. |
alias:str | Name the derived table is referred to by. |
first:Any, optional | Left-hand column of the ON condition, or a join callable. |
operator:str or None, optional | Comparison operator relating both sides. |
second:str or None, optional | Right-hand column of the ON condition. |
| Returns | |
IQueryBuilderBase | The same builder, enabling fluent chaining. |
Order the query by a timestamp column in descending order.
| Parameters | |
column:str or None, optional | Column to sort by; defaults to the creation timestamp. |
| Returns | |
IQueryBuilderBase | The same builder, enabling fluent chaining. |
str | TableDefinition, first: Any = None, operator: str | None = None, second: str | None = None, *, alias: str | None = None) -> Self:
(source)
¶
Add a LEFT OUTER JOIN to the query.
| Parameters | |
table:str or TableDefinition | Table name to join, or its full definition. |
first:Any, optional | Left-hand column of the ON condition, or a join callable. |
operator:str or None, optional | Comparison operator relating both sides. |
second:str or None, optional | Right-hand column of the ON condition. |
alias:str or None, optional | Alias the joined table is referred to by. |
| Returns | |
IQueryBuilderBase | The same builder, enabling fluent chaining. |
Any, alias: str, first: Any = None, operator: str | None = None, second: str | None = None) -> Self:
(source)
¶
Join a subquery as a derived table with a LEFT OUTER JOIN.
| Parameters | |
query:Any | Subquery source producing the derived table. |
alias:str | Name the derived table is referred to by. |
first:Any, optional | Left-hand column of the ON condition, or a join callable. |
operator:str or None, optional | Comparison operator relating both sides. |
second:str or None, optional | Right-hand column of the ON condition. |
| Returns | |
IQueryBuilderBase | The same builder, enabling fluent chaining. |
Limit the number of rows returned by the query.
| Parameters | |
value:int | Maximum number of rows, must not be negative. |
| Returns | |
IQueryBuilderBase | The same builder, enabling fluent chaining. |
Lock the selected rows against concurrent writes.
| Returns | |
IQueryBuilderBase | The same builder, enabling fluent chaining. |
Skip the given number of rows before returning results.
| Parameters | |
value:int | Number of rows to skip, must not be negative. |
| Returns | |
IQueryBuilderBase | The same builder, enabling fluent chaining. |
Order the query by a timestamp column in ascending order.
| Parameters | |
column:str or None, optional | Column to sort by; defaults to the creation timestamp. |
| Returns | |
IQueryBuilderBase | The same builder, enabling fluent chaining. |
Add an ordering rule to the query.
| Parameters | |
column:str | Column to sort by. |
direction:str, optional | "asc" or "desc". Defaults to ascending. |
| Returns | |
IQueryBuilderBase | The same builder, enabling fluent chaining. |
Add an OR-combined post-grouping condition to the query.
| Parameters | |
column:Any | Column name, mapping of equality pairs, or grouping callable. |
*args:Any | Either the bound value, or an operator followed by a value. |
| Returns | |
IQueryBuilderBase | The same builder, enabling fluent chaining. |
Add an OR-combined filtering condition.
| Parameters | |
column:Any | Column name, mapping of equality pairs, or grouping callable. |
*args:Any | Either the bound value, or an operator followed by a value. |
| Returns | |
IQueryBuilderBase | The same builder, enabling fluent chaining. |
Add an OR-combined comparison between two columns.
| Parameters | |
first:str | Left-hand column reference, optionally qualified. |
operator:str | Comparison operator relating both sides. |
second:str | Right-hand column reference, optionally qualified. |
| Returns | |
IQueryBuilderBase | The same builder, enabling fluent chaining. |
Add an OR-combined EXISTS condition.
| Parameters | |
query:Any | Subquery source producing the correlated rows. |
| Returns | |
IQueryBuilderBase | The same builder, enabling fluent chaining. |
Add an OR-combined set-membership condition.
| Parameters | |
column:str | Column name to filter by. |
values:Any | Accepted values, or a subquery producing them. |
| Returns | |
IQueryBuilderBase | The same builder, enabling fluent chaining. |
Add an OR-combined NOT EXISTS condition.
| Parameters | |
query:Any | Subquery source producing the correlated rows. |
| Returns | |
IQueryBuilderBase | The same builder, enabling fluent chaining. |
Add an OR-combined set-exclusion condition.
| Parameters | |
column:str | Column name to filter by. |
values:Any | Rejected values, or a subquery producing them. |
| Returns | |
IQueryBuilderBase | The same builder, enabling fluent chaining. |
Add an OR-combined IS NOT NULL condition.
| Parameters | |
column:str | Column name to filter by. |
| Returns | |
IQueryBuilderBase | The same builder, enabling fluent chaining. |
Add an OR-combined IS NULL condition.
| Parameters | |
column:str | Column name to filter by. |
| Returns | |
IQueryBuilderBase | The same builder, enabling fluent chaining. |
Add an OR-combined raw SQL condition.
| Parameters | |
sql:str | SQL fragment using named :param placeholders. |
bindings:dict or None, optional | Values bound to the placeholders of the fragment. |
| Returns | |
IQueryBuilderBase | The same builder, enabling fluent chaining. |
str | TableDefinition, first: Any = None, operator: str | None = None, second: str | None = None, *, alias: str | None = None) -> Self:
(source)
¶
Add a RIGHT OUTER JOIN to the query.
| Parameters | |
table:str or TableDefinition | Table name to join, or its full definition. |
first:Any, optional | Left-hand column of the ON condition, or a join callable. |
operator:str or None, optional | Comparison operator relating both sides. |
second:str or None, optional | Right-hand column of the ON condition. |
alias:str or None, optional | Alias the joined table is referred to by. |
| Returns | |
IQueryBuilderBase | The same builder, enabling fluent chaining. |
Any, alias: str, first: Any = None, operator: str | None = None, second: str | None = None) -> Self:
(source)
¶
Join a subquery as a derived table with a RIGHT OUTER JOIN.
| Parameters | |
query:Any | Subquery source producing the derived table. |
alias:str | Name the derived table is referred to by. |
first:Any, optional | Left-hand column of the ON condition, or a join callable. |
operator:str or None, optional | Comparison operator relating both sides. |
second:str or None, optional | Right-hand column of the ON condition. |
| Returns | |
IQueryBuilderBase | The same builder, enabling fluent chaining. |
Restrict the query projection to the given columns.
| Parameters | |
*columns:str | Column names to project; empty selects every column. |
| Returns | |
IQueryBuilderBase | The same builder, enabling fluent chaining. |
str, bindings: dict[ str, Any] | None = None, alias: str | None = None) -> Self:
(source)
¶
Append a raw SQL fragment to the projection.
| Parameters | |
sql:str | SQL fragment using named :param placeholders. |
bindings:dict or None, optional | Values bound to the placeholders of the fragment. |
alias:str or None, optional | Name the fragment is projected under. |
| Returns | |
IQueryBuilderBase | The same builder, enabling fluent chaining. |
Append a scalar subquery to the projection under an alias.
| Parameters | |
query:Any | Callable receiving a fresh builder, another builder, or a ready-made select plan. |
alias:str | Name the projected value is exposed under. |
| Returns | |
IQueryBuilderBase | The same builder, enabling fluent chaining. |
Lock the selected rows in shared mode.
| Returns | |
IQueryBuilderBase | The same builder, enabling fluent chaining. |
Skip the given number of rows; alias of offset.
| Parameters | |
value:int | Number of rows to skip, must not be negative. |
| Returns | |
IQueryBuilderBase | The same builder, enabling fluent chaining. |
Limit the number of rows returned; alias of limit.
| Parameters | |
value:int | Maximum number of rows, must not be negative. |
| Returns | |
IQueryBuilderBase | The same builder, enabling fluent chaining. |
Append another query's rows, collapsing duplicates.
| Parameters | |
query:Any | Subquery source whose rows are appended. |
| Returns | |
IQueryBuilderBase | The same builder, enabling fluent chaining. |
Append another query's rows, keeping duplicates.
| Parameters | |
query:Any | Subquery source whose rows are appended. |
| Returns | |
IQueryBuilderBase | The same builder, enabling fluent chaining. |
Add an AND-combined filtering condition.
| Parameters | |
column:Any | Column name, mapping of equality pairs, or a callable receiving a nested builder whose conditions are grouped in parentheses. |
*args:Any | Either the bound value, or an operator followed by a value. |
| Returns | |
IQueryBuilderBase | The same builder, enabling fluent chaining. |
Filter rows whose column value lies between two boundaries.
| Parameters | |
column:str | Column name to filter by. |
bounds:Iterable | Exactly two values: the lower and upper boundaries. |
| Returns | |
IQueryBuilderBase | The same builder, enabling fluent chaining. |
Compare two columns of the query against each other.
| Parameters | |
first:str | Left-hand column reference, optionally qualified. |
operator:str | Comparison operator relating both sides. |
second:str | Right-hand column reference, optionally qualified. |
| Returns | |
IQueryBuilderBase | The same builder, enabling fluent chaining. |
Filter rows whose column value contains the given text.
| Parameters | |
column:str | Column name to filter by. |
value:str | Literal substring to match. |
| Returns | |
IQueryBuilderBase | The same builder, enabling fluent chaining. |
Filter rows whose column value ends with the given text.
| Parameters | |
column:str | Column name to filter by. |
value:str | Literal suffix to match. |
| Returns | |
IQueryBuilderBase | The same builder, enabling fluent chaining. |
Keep rows for which a correlated subquery returns any row.
| Parameters | |
query:Any | Callable receiving a fresh builder, another builder, or a ready-made select plan. |
| Returns | |
IQueryBuilderBase | The same builder, enabling fluent chaining. |
Filter rows matching a case-insensitive SQL LIKE pattern.
| Parameters | |
column:str | Column name to filter by. |
pattern:str | SQL LIKE pattern, using % and _ wildcards. |
| Returns | |
IQueryBuilderBase | The same builder, enabling fluent chaining. |
Filter rows whose column value belongs to the given set.
| Parameters | |
column:str | Column name to filter by. |
values:Any | Accepted values, or a subquery producing them. |
| Returns | |
IQueryBuilderBase | The same builder, enabling fluent chaining. |
Filter rows whose column value matches an SQL LIKE pattern.
| Parameters | |
column:str | Column name to filter by. |
pattern:str | SQL LIKE pattern, using % and _ wildcards. |
| Returns | |
IQueryBuilderBase | The same builder, enabling fluent chaining. |
Filter rows whose column value lies outside two boundaries.
| Parameters | |
column:str | Column name to filter by. |
bounds:Iterable | Exactly two values: the lower and upper boundaries. |
| Returns | |
IQueryBuilderBase | The same builder, enabling fluent chaining. |
Keep rows for which a correlated subquery returns no row.
| Parameters | |
query:Any | Subquery source producing the correlated rows. |
| Returns | |
IQueryBuilderBase | The same builder, enabling fluent chaining. |
Filter rows not matching a case-insensitive LIKE pattern.
| Parameters | |
column:str | Column name to filter by. |
pattern:str | SQL LIKE pattern, using % and _ wildcards. |
| Returns | |
IQueryBuilderBase | The same builder, enabling fluent chaining. |
Filter rows whose column value is outside the given set.
| Parameters | |
column:str | Column name to filter by. |
values:Any | Rejected values, or a subquery producing them. |
| Returns | |
IQueryBuilderBase | The same builder, enabling fluent chaining. |
Filter rows not matching an SQL LIKE pattern.
| Parameters | |
column:str | Column name to filter by. |
pattern:str | SQL LIKE pattern, using % and _ wildcards. |
| Returns | |
IQueryBuilderBase | The same builder, enabling fluent chaining. |
Filter rows whose column value is not NULL.
| Parameters | |
column:str | Column name to filter by. |
| Returns | |
IQueryBuilderBase | The same builder, enabling fluent chaining. |
Filter rows whose column value is NULL.
| Parameters | |
column:str | Column name to filter by. |
| Returns | |
IQueryBuilderBase | The same builder, enabling fluent chaining. |
Add an AND-combined raw SQL condition.
| Parameters | |
sql:str | SQL fragment using named :param placeholders. |
bindings:dict or None, optional | Values bound to the placeholders of the fragment. |
| Returns | |
IQueryBuilderBase | The same builder, enabling fluent chaining. |
Filter rows whose column value matches a regular expression.
| Parameters | |
column:str | Column name to filter by. |
pattern:str | Regular expression pattern. |
| Returns | |
IQueryBuilderBase | The same builder, enabling fluent chaining. |
Filter rows whose column value starts with the given text.
| Parameters | |
column:str | Column name to filter by. |
value:str | Literal prefix to match. |
| Returns | |
IQueryBuilderBase | The same builder, enabling fluent chaining. |
orionis.orm.contracts.IModelQueryBuilder, orionis.orm.contracts.raw_builder.IRawQueryBuilderUndocumented