base#

Application ORM configuration.

class litestar.contrib.sqlalchemy.base.AuditColumns#

Bases: object

Created/Updated At Fields Mixin.

created_at: Mapped[datetime] = <sqlalchemy.orm.properties.MappedColumn object>#

Date/time of instance creation.

updated_at: Mapped[datetime] = <sqlalchemy.orm.properties.MappedColumn object>#

Date/time of instance last update.

class litestar.contrib.sqlalchemy.base.BigIntAuditBase#

Bases: CommonTableAttributes, BigIntPrimaryKey, AuditColumns, DeclarativeBase

Base for declarative models with BigInt primary keys and audit columns.

__init__(**kwargs: Any) None#

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

metadata: ClassVar[MetaData] = MetaData()#

Refers to the _schema.MetaData collection that will be used for new _schema.Table objects.

registry: ClassVar[_RegistryType] = <sqlalchemy.orm.decl_api.registry object>#

Refers to the _orm.registry in use where new _orm.Mapper objects will be associated.

class litestar.contrib.sqlalchemy.base.BigIntBase#

Bases: BigIntPrimaryKey, CommonTableAttributes, DeclarativeBase

Base for all SQLAlchemy declarative models with BigInt primary keys.

__init__(**kwargs: Any) None#

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

metadata: ClassVar[MetaData] = MetaData()#

Refers to the _schema.MetaData collection that will be used for new _schema.Table objects.

registry: ClassVar[_RegistryType] = <sqlalchemy.orm.decl_api.registry object>#

Refers to the _orm.registry in use where new _orm.Mapper objects will be associated.

class litestar.contrib.sqlalchemy.base.BigIntPrimaryKey#

Bases: object

BigInt Primary Key Field Mixin.

id#

BigInt Primary key column.

class litestar.contrib.sqlalchemy.base.CommonTableAttributes#

Bases: BasicAttributes

Common attributes for SQLALchemy tables.

litestar.contrib.sqlalchemy.base.create_registry(custom_annotation_map: dict[Any, type[TypeEngine[Any]] | TypeEngine[Any]] | None = None) registry#

Create a new SQLAlchemy registry.

class litestar.contrib.sqlalchemy.base.ModelProtocol#

Bases: Protocol

The base SQLAlchemy model protocol.

to_dict(exclude: set[str] | None = None) dict[str, Any]#

Convert model to dictionary.

Returns:

A dict representation of the model

Return type:

dict[str, Any]

__init__(*args, **kwargs)#
litestar.contrib.sqlalchemy.base.touch_updated_timestamp(session: Session, *_: Any) None#

Set timestamp on update.

Called from SQLAlchemy’s before_flush event to bump the updated timestamp on modified instances.

Parameters:

session – The sync Session instance that underlies the async session.

class litestar.contrib.sqlalchemy.base.UUIDAuditBase#

Bases: CommonTableAttributes, UUIDPrimaryKey, AuditColumns, DeclarativeBase

Base for declarative models with UUID primary keys and audit columns.

registry: ClassVar[_RegistryType] = <sqlalchemy.orm.decl_api.registry object>#

Refers to the _orm.registry in use where new _orm.Mapper objects will be associated.

__init__(**kwargs: Any) None#

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

metadata: ClassVar[MetaData] = MetaData()#

Refers to the _schema.MetaData collection that will be used for new _schema.Table objects.

class litestar.contrib.sqlalchemy.base.UUIDBase#

Bases: UUIDPrimaryKey, CommonTableAttributes, DeclarativeBase

Base for all SQLAlchemy declarative models with UUID primary keys.

registry: ClassVar[_RegistryType] = <sqlalchemy.orm.decl_api.registry object>#

Refers to the _orm.registry in use where new _orm.Mapper objects will be associated.

__init__(**kwargs: Any) None#

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

metadata: ClassVar[MetaData] = MetaData()#

Refers to the _schema.MetaData collection that will be used for new _schema.Table objects.

class litestar.contrib.sqlalchemy.base.UUIDPrimaryKey#

Bases: object

UUID Primary Key Field Mixin.

id: Mapped[UUID] = <sqlalchemy.orm.properties.MappedColumn object>#

UUID Primary key column.