asyncio

class advanced_alchemy.config.asyncio.AlembicAsyncConfig[source]

Bases: GenericAlembicConfig

Configuration for an Async Alembic’s Config class.

__init__(script_config: str = 'alembic.ini', version_table_name: str = 'alembic_versions', version_table_schema: str | None = None, script_location: str = 'migrations', user_module_prefix: str | None = 'sa.', render_as_batch: bool = True, compare_type: bool = False, template_path: str = '/home/runner/work/advanced-alchemy/advanced-alchemy/advanced_alchemy/alembic/templates') None
class advanced_alchemy.config.asyncio.AsyncSessionConfig[source]

Bases: GenericSessionConfig[AsyncConnection, AsyncEngine, AsyncSession]

SQLAlchemy async session config.

sync_session_class

A Session subclass or other callable which will be used to construct the Session which will be proxied. This parameter may be used to provide custom Session subclasses. Defaults to the AsyncSession.sync_session_class class-level attribute.

alias of Empty

__init__(autobegin: bool | EmptyType = <class 'advanced_alchemy.utils.dataclass.Empty'>, autoflush: bool | EmptyType = <class 'advanced_alchemy.utils.dataclass.Empty'>, bind: EngineT | ConnectionT | None | EmptyType = <class 'advanced_alchemy.utils.dataclass.Empty'>, binds: dict[type[Any] | Mapper | TableClause | str, EngineT | ConnectionT] | None | EmptyType = <class 'advanced_alchemy.utils.dataclass.Empty'>, class_: type[SessionT] | EmptyType = <class 'advanced_alchemy.utils.dataclass.Empty'>, expire_on_commit: bool | EmptyType = <class 'advanced_alchemy.utils.dataclass.Empty'>, info: dict[str, Any] | None | EmptyType = <class 'advanced_alchemy.utils.dataclass.Empty'>, join_transaction_mode: JoinTransactionMode | EmptyType = <class 'advanced_alchemy.utils.dataclass.Empty'>, query_cls: type[Query] | None | EmptyType = <class 'advanced_alchemy.utils.dataclass.Empty'>, twophase: bool | EmptyType = <class 'advanced_alchemy.utils.dataclass.Empty'>, sync_session_class: type[Session] | None | EmptyType = <class 'advanced_alchemy.utils.dataclass.Empty'>) None
class advanced_alchemy.config.asyncio.SQLAlchemyAsyncConfig[source]

Bases: GenericSQLAlchemyConfig[AsyncEngine, AsyncSession, async_sessionmaker[AsyncSession]]

Async SQLAlchemy Configuration.

Note

The alembic configuration options are documented in the Alembic documentation.

create_engine_callable(**kw: Any) AsyncEngine

Callable that creates an AsyncEngine instance or instance of its subclass.

session_config: AsyncSessionConfig

Configuration options for the async_sessionmaker.

__init__(create_engine_callable: Callable[[str], AsyncEngine] = <function create_async_engine>, session_config: AsyncSessionConfig = <factory>, session_maker_class: type[async_sessionmaker[AsyncSession]] = <class 'sqlalchemy.ext.asyncio.session.async_sessionmaker'>, connection_string: str | None = None, engine_config: EngineConfig = <factory>, session_maker: Callable[[], SessionT] | None = None, engine_instance: EngineT | None = None, create_all: bool = False, metadata: MetaData | None = None, enable_touch_updated_timestamp_listener: bool = True, bind_key: str | None = None, alembic_config: AlembicAsyncConfig = <factory>) None
session_maker_class

Sessionmaker class to use.

alias of async_sessionmaker

alembic_config: AlembicAsyncConfig

Configuration for the SQLAlchemy Alembic migrations.

The configuration options are documented in the Alembic documentation.

get_session() AsyncGenerator[AsyncSession, None][source]

Get a session from the session maker.

Returns:

An async context manager that yields an AsyncSession.

Return type:

AsyncGenerator[AsyncSession, None]