anymodel.storages.sqlalchemy

SQLAlchemy-based storage implementation.

This module provides a storage backend that persists entities to SQL databases using SQLAlchemy, with support for automatic migrations.

Classes

class anymodel.storages.sqlalchemy.SqlAlchemyStorage(url, **kwargs)[source]

Bases: Storage

Storage backend for SQL databases via SQLAlchemy.

Provides persistence to any SQLAlchemy-supported database with automatic schema migration capabilities.

__init__(url, **kwargs)[source]
insert(tablename, values)[source]

Insert a new row into the table, returns the newly generated primary key.

Return type:

Mapping[str, Any]

update(tablename, identity, values)[source]

Updates an existing row in the table.

Return type:

None

find_one(tablename, criteria)[source]
Return type:

Optional[Mapping[str, Any]]

find_many(tablename, criteria, *, limit=None, offset=None)[source]
Return type:

Iterable[Mapping[str, Any]]

delete(entity)[source]
Return type:

Entity

add_table(mapper)[source]
migrate(**kwargs)[source]