sync¶
Sync SQLAlchemy configuration module.
- class advanced_alchemy.config.sync.AlembicSyncConfig[source]¶
Bases:
GenericAlembicConfig
Configuration for Alembic’s synchronous migrations.
For details see: https://alembic.sqlalchemy.org/en/latest/api/config.html
- __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.sync.SQLAlchemySyncConfig[source]¶
Bases:
GenericSQLAlchemyConfig
[Engine
,Session
,sessionmaker
[Session
]]Synchronous SQLAlchemy Configuration.
Note
The alembic configuration options are documented in the Alembic documentation.
- create_engine_callable(**kwargs: Any) Engine ¶
Callable that creates an
Engine
instance or instance of its subclass.
- session_config: SyncSessionConfig¶
Configuration options for the
sessionmaker
.
- __init__(create_engine_callable: Callable[[str], Engine] = <function create_engine>, session_config: SyncSessionConfig = <factory>, session_maker_class: type[sessionmaker[Session]] = <class 'sqlalchemy.orm.session.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: AlembicSyncConfig = <factory>) None ¶
- session_maker_class¶
Sessionmaker class to use.
alias of
sessionmaker
- alembic_config: AlembicSyncConfig¶
Configuration for the SQLAlchemy Alembic migrations.
The configuration options are documented in the Alembic documentation.
- get_session() Generator[Session, None, None] [source]¶
Get a session context manager.
- Yields:
Generator[sqlalchemy.orm.Session, None, None] – A context manager yielding an active SQLAlchemy Session.
Examples
Using the session context manager:
>>> with config.get_session() as session: ... session.execute(...)
- class advanced_alchemy.config.sync.SyncSessionConfig[source]¶
Bases:
GenericSessionConfig
[Connection
,Engine
,Session
]Configuration for synchronous SQLAlchemy sessions.
- __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'>) None ¶