ORIONIS API REFERENCE

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 documentation

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 addSelect 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 crossJoin 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 doesntExist Report whether the query matches no rows.
Async Method exists Report whether the query matches at least one row.
Method forPage Limit the query to a single page of results.
Method fullJoin Add a FULL OUTER JOIN to the query.
Method groupBy Add grouping columns to the query.
Method having Add a post-grouping condition to the query.
Method havingRaw 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 joinSub Join a subquery as a derived table with an INNER JOIN.
Method latest Order the query by a timestamp column in descending order.
Method leftJoin Add a LEFT OUTER JOIN to the query.
Method leftJoinSub Join a subquery as a derived table with a LEFT OUTER JOIN.
Method limit Limit the number of rows returned by the query.
Method lockForUpdate 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 orderBy Add an ordering rule to the query.
Method orHaving Add an OR-combined post-grouping condition to the query.
Method orWhere Add an OR-combined filtering condition.
Method orWhereColumn Add an OR-combined comparison between two columns.
Method orWhereExists Add an OR-combined EXISTS condition.
Method orWhereIn Add an OR-combined set-membership condition.
Method orWhereNotExists Add an OR-combined NOT EXISTS condition.
Method orWhereNotIn Add an OR-combined set-exclusion condition.
Method orWhereNotNull Add an OR-combined IS NOT NULL condition.
Method orWhereNull Add an OR-combined IS NULL condition.
Method orWhereRaw Add an OR-combined raw SQL condition.
Method rightJoin Add a RIGHT OUTER JOIN to the query.
Method rightJoinSub Join a subquery as a derived table with a RIGHT OUTER JOIN.
Method select Restrict the query projection to the given columns.
Method selectRaw Append a raw SQL fragment to the projection.
Method selectSub Append a scalar subquery to the projection under an alias.
Method sharedLock 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 toPlan Return the engine-agnostic plan assembled so far.
Method union Append another query's rows, collapsing duplicates.
Method unionAll 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 whereBetween Filter rows whose column value lies between two boundaries.
Method whereColumn Compare two columns of the query against each other.
Method whereContains Filter rows whose column value contains the given text.
Method whereEndsWith Filter rows whose column value ends with the given text.
Method whereExists Keep rows for which a correlated subquery returns any row.
Method whereILike Filter rows matching a case-insensitive SQL LIKE pattern.
Method whereIn Filter rows whose column value belongs to the given set.
Method whereLike Filter rows whose column value matches an SQL LIKE pattern.
Method whereNotBetween Filter rows whose column value lies outside two boundaries.
Method whereNotExists Keep rows for which a correlated subquery returns no row.
Method whereNotILike Filter rows not matching a case-insensitive LIKE pattern.
Method whereNotIn Filter rows whose column value is outside the given set.
Method whereNotLike Filter rows not matching an SQL LIKE pattern.
Method whereNotNull Filter rows whose column value is not NULL.
Method whereNull Filter rows whose column value is NULL.
Method whereRaw Add an AND-combined raw SQL condition.
Method whereRegexpMatch Filter rows whose column value matches a regular expression.
Method whereStartsWith Filter rows whose column value starts with the given text.
Class Variable __slots__ Undocumented
def addSelect(self, *columns: str) -> Self: (source)

Append columns to the current projection.

Parameters
*columns:strColumn names to add to the projection.
Returns
IQueryBuilderBaseThe same builder, enabling fluent chaining.
async def avg(self, column: str) -> float | None: (source)

Return the average value of a column among matching rows.

Parameters
column:strColumn to aggregate.
Returns
float or NoneAverage value, or None without matches.
def clone(self) -> Self: (source)

Return an independent copy of this builder.

Returns
IQueryBuilderBaseDetached copy carrying its own plan.
async def count(self, column: str = '*') -> int: (source)

Count the rows matched by the query.

Parameters
column:str, optionalColumn to count; "*" counts every matching row.
Returns
intNumber of matching rows.
def crossJoin(self, table: str | TableDefinition, *, alias: str | None = None) -> Self: (source)

Add a CROSS JOIN to the query.

Parameters
table:str or TableDefinitionTable name to join, or its full definition.
alias:str or None, optionalAlias the joined table is referred to by.
Returns
IQueryBuilderBaseThe same builder, enabling fluent chaining.
async def delete(self) -> int: (source)

Delete the rows matched by the query.

Returns
intNumber of affected rows.
def distinct(self) -> Self: (source)

Collapse duplicate rows from the query results.

Returns
IQueryBuilderBaseThe same builder, enabling fluent chaining.
async def doesntExist(self) -> bool: (source)

Report whether the query matches no rows.

Returns
boolTrue when no matching row exists.
async def exists(self) -> bool: (source)

Report whether the query matches at least one row.

Returns
boolTrue when a matching row exists.
def forPage(self, page: int, per_page: int = 15) -> Self: (source)

Limit the query to a single page of results.

Parameters
page:intPage number starting at 1.
per_page:int, optionalNumber of items per page. Defaults to 15.
Returns
IQueryBuilderBaseThe same builder, enabling fluent chaining.
def fullJoin(self, table: 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 TableDefinitionTable name to join, or its full definition.
first:Any, optionalLeft-hand column of the ON condition, or a join callable.
operator:str or None, optionalComparison operator relating both sides.
second:str or None, optionalRight-hand column of the ON condition.
alias:str or None, optionalAlias the joined table is referred to by.
Returns
IQueryBuilderBaseThe same builder, enabling fluent chaining.
def groupBy(self, *columns: str) -> Self: (source)

Add grouping columns to the query.

Parameters
*columns:strColumns to group by.
Returns
IQueryBuilderBaseThe same builder, enabling fluent chaining.
def having(self, column: Any, *args: Any) -> Self: (source)

Add a post-grouping condition to the query.

Parameters
column:AnyColumn name, mapping of equality pairs, or grouping callable.
*args:AnyEither the bound value, or an operator followed by a value.
Returns
IQueryBuilderBaseThe same builder, enabling fluent chaining.
def havingRaw(self, sql: str, bindings: dict[str, Any] | None = None) -> Self: (source)

Add a raw SQL post-grouping condition.

Parameters
sql:strSQL fragment using named :param placeholders.
bindings:dict or None, optionalValues bound to the placeholders of the fragment.
Returns
IQueryBuilderBaseThe same builder, enabling fluent chaining.
async def insert(self, values: dict[str, Any] | list[dict[str, Any]]) -> InsertResult: (source)

Insert one or many rows into the target table.

Parameters
values:dict or list of dictColumn values for one row, or a list of rows.
Returns
InsertResultResult carrying the generated key and affected row count.
def join(self, table: 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 TableDefinitionTable name to join, or its full definition.
first:Any, optionalLeft-hand column of the ON condition, or a callable receiving a join clause to declare several conditions.
operator:str or None, optionalComparison operator relating both sides.
second:str or None, optionalRight-hand column of the ON condition.
alias:str or None, optionalAlias the joined table is referred to by.
Returns
IQueryBuilderBaseThe same builder, enabling fluent chaining.
def joinSub(self, query: 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:AnySubquery source producing the derived table.
alias:strName the derived table is referred to by.
first:Any, optionalLeft-hand column of the ON condition, or a join callable.
operator:str or None, optionalComparison operator relating both sides.
second:str or None, optionalRight-hand column of the ON condition.
Returns
IQueryBuilderBaseThe same builder, enabling fluent chaining.
def latest(self, column: str | None = None) -> Self: (source)

Order the query by a timestamp column in descending order.

Parameters
column:str or None, optionalColumn to sort by; defaults to the creation timestamp.
Returns
IQueryBuilderBaseThe same builder, enabling fluent chaining.
def leftJoin(self, table: 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 TableDefinitionTable name to join, or its full definition.
first:Any, optionalLeft-hand column of the ON condition, or a join callable.
operator:str or None, optionalComparison operator relating both sides.
second:str or None, optionalRight-hand column of the ON condition.
alias:str or None, optionalAlias the joined table is referred to by.
Returns
IQueryBuilderBaseThe same builder, enabling fluent chaining.
def leftJoinSub(self, query: 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:AnySubquery source producing the derived table.
alias:strName the derived table is referred to by.
first:Any, optionalLeft-hand column of the ON condition, or a join callable.
operator:str or None, optionalComparison operator relating both sides.
second:str or None, optionalRight-hand column of the ON condition.
Returns
IQueryBuilderBaseThe same builder, enabling fluent chaining.
def limit(self, value: int) -> Self: (source)

Limit the number of rows returned by the query.

Parameters
value:intMaximum number of rows, must not be negative.
Returns
IQueryBuilderBaseThe same builder, enabling fluent chaining.
def lockForUpdate(self) -> Self: (source)

Lock the selected rows against concurrent writes.

Returns
IQueryBuilderBaseThe same builder, enabling fluent chaining.
async def max(self, column: str) -> Any: (source)

Return the maximum value of a column among matching rows.

Parameters
column:strColumn to aggregate.
Returns
AnyMaximum value, or None without matches.
async def min(self, column: str) -> Any: (source)

Return the minimum value of a column among matching rows.

Parameters
column:strColumn to aggregate.
Returns
AnyMinimum value, or None without matches.
def offset(self, value: int) -> Self: (source)

Skip the given number of rows before returning results.

Parameters
value:intNumber of rows to skip, must not be negative.
Returns
IQueryBuilderBaseThe same builder, enabling fluent chaining.
def oldest(self, column: str | None = None) -> Self: (source)

Order the query by a timestamp column in ascending order.

Parameters
column:str or None, optionalColumn to sort by; defaults to the creation timestamp.
Returns
IQueryBuilderBaseThe same builder, enabling fluent chaining.
def orderBy(self, column: str, direction: str = 'asc') -> Self: (source)

Add an ordering rule to the query.

Parameters
column:strColumn to sort by.
direction:str, optional"asc" or "desc". Defaults to ascending.
Returns
IQueryBuilderBaseThe same builder, enabling fluent chaining.
def orHaving(self, column: Any, *args: Any) -> Self: (source)

Add an OR-combined post-grouping condition to the query.

Parameters
column:AnyColumn name, mapping of equality pairs, or grouping callable.
*args:AnyEither the bound value, or an operator followed by a value.
Returns
IQueryBuilderBaseThe same builder, enabling fluent chaining.
def orWhere(self, column: Any, *args: Any) -> Self: (source)

Add an OR-combined filtering condition.

Parameters
column:AnyColumn name, mapping of equality pairs, or grouping callable.
*args:AnyEither the bound value, or an operator followed by a value.
Returns
IQueryBuilderBaseThe same builder, enabling fluent chaining.
def orWhereColumn(self, first: str, operator: str, second: str) -> Self: (source)

Add an OR-combined comparison between two columns.

Parameters
first:strLeft-hand column reference, optionally qualified.
operator:strComparison operator relating both sides.
second:strRight-hand column reference, optionally qualified.
Returns
IQueryBuilderBaseThe same builder, enabling fluent chaining.
def orWhereExists(self, query: Any) -> Self: (source)

Add an OR-combined EXISTS condition.

Parameters
query:AnySubquery source producing the correlated rows.
Returns
IQueryBuilderBaseThe same builder, enabling fluent chaining.
def orWhereIn(self, column: str, values: Any) -> Self: (source)

Add an OR-combined set-membership condition.

Parameters
column:strColumn name to filter by.
values:AnyAccepted values, or a subquery producing them.
Returns
IQueryBuilderBaseThe same builder, enabling fluent chaining.
def orWhereNotExists(self, query: Any) -> Self: (source)

Add an OR-combined NOT EXISTS condition.

Parameters
query:AnySubquery source producing the correlated rows.
Returns
IQueryBuilderBaseThe same builder, enabling fluent chaining.
def orWhereNotIn(self, column: str, values: Any) -> Self: (source)

Add an OR-combined set-exclusion condition.

Parameters
column:strColumn name to filter by.
values:AnyRejected values, or a subquery producing them.
Returns
IQueryBuilderBaseThe same builder, enabling fluent chaining.
def orWhereNotNull(self, column: str) -> Self: (source)

Add an OR-combined IS NOT NULL condition.

Parameters
column:strColumn name to filter by.
Returns
IQueryBuilderBaseThe same builder, enabling fluent chaining.
def orWhereNull(self, column: str) -> Self: (source)

Add an OR-combined IS NULL condition.

Parameters
column:strColumn name to filter by.
Returns
IQueryBuilderBaseThe same builder, enabling fluent chaining.
def orWhereRaw(self, sql: str, bindings: dict[str, Any] | None = None) -> Self: (source)

Add an OR-combined raw SQL condition.

Parameters
sql:strSQL fragment using named :param placeholders.
bindings:dict or None, optionalValues bound to the placeholders of the fragment.
Returns
IQueryBuilderBaseThe same builder, enabling fluent chaining.
def rightJoin(self, table: 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 TableDefinitionTable name to join, or its full definition.
first:Any, optionalLeft-hand column of the ON condition, or a join callable.
operator:str or None, optionalComparison operator relating both sides.
second:str or None, optionalRight-hand column of the ON condition.
alias:str or None, optionalAlias the joined table is referred to by.
Returns
IQueryBuilderBaseThe same builder, enabling fluent chaining.
def rightJoinSub(self, query: 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:AnySubquery source producing the derived table.
alias:strName the derived table is referred to by.
first:Any, optionalLeft-hand column of the ON condition, or a join callable.
operator:str or None, optionalComparison operator relating both sides.
second:str or None, optionalRight-hand column of the ON condition.
Returns
IQueryBuilderBaseThe same builder, enabling fluent chaining.
def select(self, *columns: str) -> Self: (source)

Restrict the query projection to the given columns.

Parameters
*columns:strColumn names to project; empty selects every column.
Returns
IQueryBuilderBaseThe same builder, enabling fluent chaining.
def selectRaw(self, sql: str, bindings: dict[str, Any] | None = None, alias: str | None = None) -> Self: (source)

Append a raw SQL fragment to the projection.

Parameters
sql:strSQL fragment using named :param placeholders.
bindings:dict or None, optionalValues bound to the placeholders of the fragment.
alias:str or None, optionalName the fragment is projected under.
Returns
IQueryBuilderBaseThe same builder, enabling fluent chaining.
def selectSub(self, query: Any, alias: str) -> Self: (source)

Append a scalar subquery to the projection under an alias.

Parameters
query:AnyCallable receiving a fresh builder, another builder, or a ready-made select plan.
alias:strName the projected value is exposed under.
Returns
IQueryBuilderBaseThe same builder, enabling fluent chaining.
def sharedLock(self) -> Self: (source)

Lock the selected rows in shared mode.

Returns
IQueryBuilderBaseThe same builder, enabling fluent chaining.
def skip(self, value: int) -> Self: (source)

Skip the given number of rows; alias of offset.

Parameters
value:intNumber of rows to skip, must not be negative.
Returns
IQueryBuilderBaseThe same builder, enabling fluent chaining.
async def sum(self, column: str) -> Any: (source)

Return the sum of a column among matching rows.

Parameters
column:strColumn to aggregate.
Returns
AnySum of the values, or 0 without matches.
def take(self, value: int) -> Self: (source)

Limit the number of rows returned; alias of limit.

Parameters
value:intMaximum number of rows, must not be negative.
Returns
IQueryBuilderBaseThe same builder, enabling fluent chaining.
def toPlan(self) -> SelectPlan: (source)

Return the engine-agnostic plan assembled so far.

Returns
SelectPlanLive plan owned by this builder.
def union(self, query: Any) -> Self: (source)

Append another query's rows, collapsing duplicates.

Parameters
query:AnySubquery source whose rows are appended.
Returns
IQueryBuilderBaseThe same builder, enabling fluent chaining.
def unionAll(self, query: Any) -> Self: (source)

Append another query's rows, keeping duplicates.

Parameters
query:AnySubquery source whose rows are appended.
Returns
IQueryBuilderBaseThe same builder, enabling fluent chaining.
async def update(self, values: dict[str, Any]) -> int: (source)

Mass update the rows matched by the query.

Parameters
values:dictColumn values to assign.
Returns
intNumber of affected rows.
def where(self, column: Any, *args: Any) -> Self: (source)

Add an AND-combined filtering condition.

Parameters
column:AnyColumn name, mapping of equality pairs, or a callable receiving a nested builder whose conditions are grouped in parentheses.
*args:AnyEither the bound value, or an operator followed by a value.
Returns
IQueryBuilderBaseThe same builder, enabling fluent chaining.
def whereBetween(self, column: str, bounds: Iterable[Any]) -> Self: (source)

Filter rows whose column value lies between two boundaries.

Parameters
column:strColumn name to filter by.
bounds:IterableExactly two values: the lower and upper boundaries.
Returns
IQueryBuilderBaseThe same builder, enabling fluent chaining.
def whereColumn(self, first: str, operator: str, second: str) -> Self: (source)

Compare two columns of the query against each other.

Parameters
first:strLeft-hand column reference, optionally qualified.
operator:strComparison operator relating both sides.
second:strRight-hand column reference, optionally qualified.
Returns
IQueryBuilderBaseThe same builder, enabling fluent chaining.
def whereContains(self, column: str, value: str) -> Self: (source)

Filter rows whose column value contains the given text.

Parameters
column:strColumn name to filter by.
value:strLiteral substring to match.
Returns
IQueryBuilderBaseThe same builder, enabling fluent chaining.
def whereEndsWith(self, column: str, value: str) -> Self: (source)

Filter rows whose column value ends with the given text.

Parameters
column:strColumn name to filter by.
value:strLiteral suffix to match.
Returns
IQueryBuilderBaseThe same builder, enabling fluent chaining.
def whereExists(self, query: Any) -> Self: (source)

Keep rows for which a correlated subquery returns any row.

Parameters
query:AnyCallable receiving a fresh builder, another builder, or a ready-made select plan.
Returns
IQueryBuilderBaseThe same builder, enabling fluent chaining.
def whereILike(self, column: str, pattern: str) -> Self: (source)

Filter rows matching a case-insensitive SQL LIKE pattern.

Parameters
column:strColumn name to filter by.
pattern:strSQL LIKE pattern, using % and _ wildcards.
Returns
IQueryBuilderBaseThe same builder, enabling fluent chaining.
def whereIn(self, column: str, values: Any) -> Self: (source)

Filter rows whose column value belongs to the given set.

Parameters
column:strColumn name to filter by.
values:AnyAccepted values, or a subquery producing them.
Returns
IQueryBuilderBaseThe same builder, enabling fluent chaining.
def whereLike(self, column: str, pattern: str) -> Self: (source)

Filter rows whose column value matches an SQL LIKE pattern.

Parameters
column:strColumn name to filter by.
pattern:strSQL LIKE pattern, using % and _ wildcards.
Returns
IQueryBuilderBaseThe same builder, enabling fluent chaining.
def whereNotBetween(self, column: str, bounds: Iterable[Any]) -> Self: (source)

Filter rows whose column value lies outside two boundaries.

Parameters
column:strColumn name to filter by.
bounds:IterableExactly two values: the lower and upper boundaries.
Returns
IQueryBuilderBaseThe same builder, enabling fluent chaining.
def whereNotExists(self, query: Any) -> Self: (source)

Keep rows for which a correlated subquery returns no row.

Parameters
query:AnySubquery source producing the correlated rows.
Returns
IQueryBuilderBaseThe same builder, enabling fluent chaining.
def whereNotILike(self, column: str, pattern: str) -> Self: (source)

Filter rows not matching a case-insensitive LIKE pattern.

Parameters
column:strColumn name to filter by.
pattern:strSQL LIKE pattern, using % and _ wildcards.
Returns
IQueryBuilderBaseThe same builder, enabling fluent chaining.
def whereNotIn(self, column: str, values: Any) -> Self: (source)

Filter rows whose column value is outside the given set.

Parameters
column:strColumn name to filter by.
values:AnyRejected values, or a subquery producing them.
Returns
IQueryBuilderBaseThe same builder, enabling fluent chaining.
def whereNotLike(self, column: str, pattern: str) -> Self: (source)

Filter rows not matching an SQL LIKE pattern.

Parameters
column:strColumn name to filter by.
pattern:strSQL LIKE pattern, using % and _ wildcards.
Returns
IQueryBuilderBaseThe same builder, enabling fluent chaining.
def whereNotNull(self, column: str) -> Self: (source)

Filter rows whose column value is not NULL.

Parameters
column:strColumn name to filter by.
Returns
IQueryBuilderBaseThe same builder, enabling fluent chaining.
def whereNull(self, column: str) -> Self: (source)

Filter rows whose column value is NULL.

Parameters
column:strColumn name to filter by.
Returns
IQueryBuilderBaseThe same builder, enabling fluent chaining.
def whereRaw(self, sql: str, bindings: dict[str, Any] | None = None) -> Self: (source)

Add an AND-combined raw SQL condition.

Parameters
sql:strSQL fragment using named :param placeholders.
bindings:dict or None, optionalValues bound to the placeholders of the fragment.
Returns
IQueryBuilderBaseThe same builder, enabling fluent chaining.
def whereRegexpMatch(self, column: str, pattern: str) -> Self: (source)

Filter rows whose column value matches a regular expression.

Parameters
column:strColumn name to filter by.
pattern:strRegular expression pattern.
Returns
IQueryBuilderBaseThe same builder, enabling fluent chaining.
def whereStartsWith(self, column: str, value: str) -> Self: (source)

Filter rows whose column value starts with the given text.

Parameters
column:strColumn name to filter by.
value:strLiteral prefix to match.
Returns
IQueryBuilderBaseThe same builder, enabling fluent chaining.