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

class Blueprint: (source)

Constructor: Blueprint()

View In Hierarchy

Fluent collector of column definitions for a single table.

Instances are yielded by Schema.create(name) when used as an async context manager (async with schema.create(name) as table:), allowing columns to be declared one call at a time instead of passing every definition up front. Table-level constraints (Comment, ForeignKey, Index, PrimaryKey, Unique) are declared the same way, via table.comment(...), table.foreignKey(...), table.index(...), table.primaryKey(...) and table.unique(...).

Method __getattr__ Proxy a column-factory call to Column, recording it.
Method __init__ Initialize the blueprint with no columns declared yet.
Method columns Return the columns declared so far, in declaration order.
Method comment Attach a table-level comment.
Method definitions Return every column and table-level constraint declared so far.
Method foreignKey Declare a foreign key constraint on this table.
Method index Declare an index over one or more columns.
Method primaryKey Declare a (composite) primary key over one or more columns.
Method timestamps Add nullable created_at and updated_at columns.
Method unique Declare a unique constraint over one or more columns.
Class Variable __slots__ Undocumented
Instance Variable __columns Undocumented
Instance Variable __constraints Undocumented
Instance Variable __factory_cache Undocumented
def __getattr__(self, name: str) -> Callable[..., ColumnDefinition]: (source)

Proxy a column-factory call to Column, recording it.

This is what powers calls such as table.string("username") or table.boolean("is_admin"): any factory exposed by Column becomes available on the blueprint, and the resulting column is appended to this table automatically.

Parameters
name:strName of the Column factory method being invoked.
Returns
Callable[..., ColumnDefinition]Wrapper that builds the column and appends it to this table.
Raises
AttributeErrorIf name does not match a known Column factory method.
def __init__(self): (source)

Initialize the blueprint with no columns declared yet.

Returns
NoneThis method does not return a value.
def columns(self) -> tuple[ColumnDefinition, ...]: (source)

Return the columns declared so far, in declaration order.

Returns
tuple of ColumnDefinitionSnapshot of every column recorded on this blueprint.
def comment(self, text: str) -> Comment: (source)

Attach a table-level comment.

Parameters
text:strThe comment text content.
Returns
CommentThe constraint recorded on this blueprint.
def definitions(self) -> tuple[ColumnDefinition | Comment | ForeignKey | Index | PrimaryKey | Unique, ...]: (source)

Return every column and table-level constraint declared so far.

Returns
tupleColumns followed by constraints, in the order each group was recorded on this blueprint.
def foreignKey(self, column: str, ref_table: str, ref_column: str, name: str | None = None) -> ForeignKey: (source)

Declare a foreign key constraint on this table.

Parameters
column:strThe local column name.
ref_table:strThe referenced table name.
ref_column:strThe referenced column name.
name:str | None, optionalThe constraint name. Defaults to None.
Returns
ForeignKeyThe constraint recorded on this blueprint.
def index(self, *columns: str, name: str | None = None, unique: bool = False) -> Index: (source)

Declare an index over one or more columns.

Parameters
*columns:strColumn names to include in the index.
name:str | None, optionalName of the index. If not provided, a default name will be generated.
unique:bool, optionalWhether the index should enforce uniqueness. Default is False.
Returns
IndexThe constraint recorded on this blueprint.
def primaryKey(self, *columns: str) -> PrimaryKey: (source)

Declare a (composite) primary key over one or more columns.

Parameters
*columns:strColumn names that compose the primary key.
Returns
PrimaryKeyThe constraint recorded on this blueprint.
def timestamps(self, *, timezone: bool = False): (source)

Add nullable created_at and updated_at columns.

Parameters
timezone:bool, optionalWhether the timestamp columns should be timezone-aware.
Returns
NoneThis method does not return a value.
def unique(self, *columns: str, name: str | None = None) -> Unique: (source)

Declare a unique constraint over one or more columns.

Parameters
*columns:strColumn names to apply the unique constraint to.
name:str | None, optionalName of the unique constraint. If not provided, a default name will be generated.
Returns
UniqueThe constraint recorded on this blueprint.
__slots__: tuple[str, ...] = (source)

Undocumented

__columns: list[ColumnDefinition] = (source)

Undocumented

Undocumented

__factory_cache: dict[str, Callable[..., ColumnDefinition]] = (source)

Undocumented