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

Named database connection encapsulating the SQL engine.

The connection lazily builds its async engine from the Orionis configuration, compiles query plans through SQLCompiler, and exposes only framework-owned types: dictionaries, integers, and result entities. Transactions are task-local and support nesting through savepoints.

Method __init__ Initialize the connection with its configuration.
Method _acquire Resolve the connection context to execute statements on.
Method _getEngine Build the async engine on first use and cache it.
Method _queryException Create a query exception without exposing SQL or bound values.
Async Method _releaseIfSettled Close the raw connection once every transaction level is settled.
Async Method _run Execute a statement translating engine errors into Orionis errors.
Method _transactionState Resolve the transaction owned by the current asyncio task.
Async Method begin Begin a transaction, or a savepoint when one is already active.
Async Method commit Commit the innermost active transaction or savepoint.
Async Method createTable Create the physical table described by the given definition.
Async Method delete Run a DELETE statement described by the given plan.
Async Method disconnect Dispose the underlying engine and release its pooled resources.
Async Method dropTable Drop the physical table with the given logical name.
Async Method execute Run a raw data-modifying SQL statement.
Method getName Return the configured name of this connection.
Async Method insert Run an INSERT statement described by the given plan.
Method inTransaction Report whether a transaction is active in the current task.
Async Method rollback Roll back the innermost active transaction or savepoint.
Async Method scalar Run a SELECT plan and return the first column of the first row.
Async Method select Run a SELECT query and return its rows as dictionaries.
Async Method statement Run a raw SQL statement without inspecting its result.
Method transaction Return a transaction usable as an async context manager.
Async Method update Run an UPDATE statement described by the given plan.
Class Variable __slots__ Undocumented
Instance Variable _compiler Undocumented
Instance Variable _config Undocumented
Instance Variable _engine Undocumented
Instance Variable _name Undocumented
Instance Variable _tx_state Undocumented
def __init__(self, name: str, config: dict[str, Any]): (source)

Initialize the connection with its configuration.

Parameters
name:strConnection name as registered in the manager.
config:dictDriver configuration for the connection.
Returns
NoneThis method does not return a value.
Raises
UnsupportedDriverExceptionIf the configured driver has no registered dialect.
def _acquire(self) -> AbstractAsyncContextManager[AsyncConnection] | _TransactionState: (source)

Resolve the connection context to execute statements on.

Inside a transaction the transactional connection is reused; otherwise an ephemeral autocommit connection is opened. The context manager is returned directly to the caller.

Returns
AbstractAsyncContextManagerContext manager yielding the connection to execute on.
def _getEngine(self) -> AsyncEngine: (source)

Build the async engine on first use and cache it.

Returns
AsyncEngineConfigured engine for this connection.
Raises
MissingDatabaseDependencyExceptionIf the async driver package is not installed.
def _queryException(self, error: SQLAlchemyError) -> QueryException: (source)

Create a query exception without exposing SQL or bound values.

Parameters
error:SQLAlchemyErrorDatabase error whose type identifies the failure.
Returns
QueryExceptionSanitized exception identifying the connection and error type.
async def _releaseIfSettled(self, state: _TransactionState): (source)

Close the raw connection once every transaction level is settled.

Parameters
state:_TransactionStateTransaction state to inspect and release.
Returns
NoneThis method does not return a value.
async def _run(self, connection: AsyncConnection, statement: Any, parameters: Mapping[str, Any] | Sequence[Mapping[str, Any]] | None = None) -> CursorResult[Any]: (source)

Execute a statement translating engine errors into Orionis errors.

Parameters
connection:AsyncConnectionRaw connection to execute on.
statement:AnyExecutable statement or textual clause.
parameters:Mapping, Sequence of Mapping or None, optionalBound parameters for a statement or a batch of row mappings.
Returns
CursorResultRaw execution result, consumed internally by callers.
Raises
QueryExceptionIf the statement fails to execute.
def _transactionState(self) -> _TransactionState | None: (source)

Resolve the transaction owned by the current asyncio task.

Returns
_TransactionState | NoneResult of the operation described above.
async def begin(self): (source)

Begin a transaction, or a savepoint when one is already active.

Returns
NoneThis method does not return a value.
Raises
TransactionExceptionIf the transaction cannot be started.
async def commit(self): (source)

Commit the innermost active transaction or savepoint.

Returns
NoneThis method does not return a value.
Raises
TransactionExceptionIf no transaction is active or the commit fails.
async def createTable(self, table: TableDefinition, *, if_not_exists: bool = True) -> bool: (source)

Create the physical table described by the given definition.

Parameters
table:TableDefinitionTable definition to materialize.
if_not_exists:bool, optionalWhether to guard the statement with IF NOT EXISTS so that an already existing table is silently kept.
Returns
boolTrue when the statement executes without errors.
Raises
QueryExceptionIf the DDL statement fails to execute.
async def delete(self, plan: DeletePlan) -> int: (source)

Run a DELETE statement described by the given plan.

Parameters
plan:DeletePlanDelete plan with filtering conditions.
Returns
intNumber of affected rows.
Raises
QueryExceptionIf the statement fails to compile or execute.
async def disconnect(self): (source)

Dispose the underlying engine and release its pooled resources.

Returns
NoneThis method does not return a value.
async def dropTable(self, name: str, schema: str | None = None, *, if_exists: bool = True) -> bool: (source)

Drop the physical table with the given logical name.

Parameters
name:strLogical table name; the connection prefix is applied.
schema:str or None, optionalDatabase schema owning the table, or None for the default.
if_exists:bool, optionalWhether to guard the statement with IF EXISTS so that a missing table does not raise an error.
Returns
boolTrue when the statement executes without errors.
Raises
QueryExceptionIf the DDL statement fails to execute.
async def execute(self, sql: str, bindings: Mapping[str, Any] | None = None) -> int: (source)

Run a raw data-modifying SQL statement.

Parameters
sql:strRaw SQL using named :param placeholders.
bindings:Mapping of str to Any, optionalBound parameters for the statement.
Returns
intNumber of affected rows.
Raises
QueryExceptionIf the statement fails to execute. Driver messages and bound values are excluded because they may contain credentials.
def getName(self) -> str: (source)

Return the configured name of this connection.

Returns
strConnection name as registered in the manager.
async def insert(self, plan: InsertPlan) -> InsertResult: (source)

Run an INSERT statement described by the given plan.

Parameters
plan:InsertPlanInsert plan with the target table and row values.
Returns
InsertResultResult carrying the generated key and affected row count.
Raises
QueryExceptionIf the statement fails to compile or execute.
def inTransaction(self) -> bool: (source)

Report whether a transaction is active in the current task.

Returns
boolTrue when at least one transaction level is open.
async def rollback(self): (source)

Roll back the innermost active transaction or savepoint.

Returns
NoneThis method does not return a value.
Raises
TransactionExceptionIf no transaction is active or the rollback fails.
async def scalar(self, plan: SelectPlan) -> Any: (source)

Run a SELECT plan and return the first column of the first row.

Parameters
plan:SelectPlanQuery plan, typically carrying an aggregate projection.
Returns
AnyScalar value, or None when the query yields no rows.
Raises
QueryExceptionIf the statement fails to compile or execute.
async def select(self, query: SelectPlan | str, bindings: Mapping[str, Any] | None = None) -> list[dict[str, Any]]: (source)

Run a SELECT query and return its rows as dictionaries.

Parameters
query:SelectPlan or strCompiled query plan, or a raw SQL string using named :param placeholders.
bindings:Mapping of str to Any, optionalBound parameters for raw SQL strings.
Returns
list of dictOne dictionary per row keyed by column name.
Raises
QueryExceptionIf the statement fails to compile or execute.
async def statement(self, sql: str, bindings: Mapping[str, Any] | None = None) -> bool: (source)

Run a raw SQL statement without inspecting its result.

Intended for DDL and maintenance commands.

Parameters
sql:strRaw SQL statement.
bindings:Mapping of str to Any, optionalBound parameters for the statement.
Returns
boolTrue when the statement executes without errors.
Raises
QueryExceptionIf the statement fails to execute.
def transaction(self) -> ITransaction: (source)

Return a transaction usable as an async context manager.

Returns
ITransactionContext manager committing on success and rolling back on error.
async def update(self, plan: UpdatePlan) -> int: (source)

Run an UPDATE statement described by the given plan.

Parameters
plan:UpdatePlanUpdate plan with values and filtering conditions.
Returns
intNumber of affected rows.
Raises
QueryExceptionIf the statement fails to compile or execute.
_compiler = (source)

Undocumented

Undocumented

_engine: AsyncEngine | None = (source)

Undocumented

Undocumented

_tx_state: ContextVar[_TransactionState | None] = (source)

Undocumented