PostgreSQL¶
The postgres/sqlalchemy adapter provides a PostgreSQL-specific SQLAlchemy integration, including a concrete adapter,
session manager, and session manager registry that extend the base SQLAlchemy components.
Session Managers¶
PostgreSQL-specific session manager handling connection pooling and lifecycle for PostgreSQL databases.
Classes:
| Name | Description |
|---|---|
PostgresSQlAlchemySessionManager |
Synchronous SQLAlchemy session manager for PostgreSQL. |
AsyncPostgresSQlAlchemySessionManager |
Asynchronous SQLAlchemy session manager for PostgreSQL. |
PostgresSQlAlchemySessionManager ¶
Synchronous SQLAlchemy session manager for PostgreSQL.
Inherits from BaseSQLAlchemySessionManager to provide PostgreSQL-specific session management, including connection URL creation and engine configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
orm_config
|
PostgresSQLAlchemyConfig | None
|
PostgreSQL-specific configuration. If None, uses global config. |
None
|
Source code in archipy/adapters/postgres/sqlalchemy/session_managers.py
AsyncPostgresSQlAlchemySessionManager ¶
Asynchronous SQLAlchemy session manager for PostgreSQL.
Inherits from AsyncBaseSQLAlchemySessionManager to provide async PostgreSQL-specific session management, including connection URL creation and async engine configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
orm_config
|
PostgresSQLAlchemyConfig | None
|
PostgreSQL-specific configuration. If None, uses global config. |
None
|
Source code in archipy/adapters/postgres/sqlalchemy/session_managers.py
options: show_root_toc_entry: false heading_level: 3
Session Manager Registry¶
Registry for PostgreSQL session manager instances.
Classes:
| Name | Description |
|---|---|
PostgresSessionManagerRegistry |
Registry for PostgreSQL SQLAlchemy session managers. |
PostgresSessionManagerRegistry ¶
Registry for PostgreSQL SQLAlchemy session managers.
This registry provides a centralized access point for both synchronous and asynchronous PostgreSQL session managers, implementing the Service Locator pattern. It lazily initializes the appropriate session manager when first requested.
The registry maintains singleton instances of: - A synchronous session manager (PostgresSQlAlchemySessionManager) - An asynchronous session manager (AsyncPostgresSQlAlchemySessionManager)
Methods:
| Name | Description |
|---|---|
get_sync_manager |
Get the synchronous PostgreSQL session manager instance. |
set_sync_manager |
Set a custom synchronous session manager. |
get_async_manager |
Get the asynchronous PostgreSQL session manager instance. |
set_async_manager |
Set a custom asynchronous session manager. |
reset |
Reset the registry to its initial state. |
Source code in archipy/adapters/postgres/sqlalchemy/session_manager_registry.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | |
get_sync_manager
classmethod
¶
Get the synchronous PostgreSQL session manager instance.
Lazily initializes a default PostgresSQlAlchemySessionManager if none has been set.
Returns:
| Name | Type | Description |
|---|---|---|
SessionManagerPort |
SessionManagerPort
|
The registered synchronous session manager |
Raises:
| Type | Description |
|---|---|
DatabaseConnectionError
|
If there's an error initializing the session manager |
Source code in archipy/adapters/postgres/sqlalchemy/session_manager_registry.py
set_sync_manager
classmethod
¶
Set a custom synchronous session manager.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
manager
|
SessionManagerPort
|
An instance implementing SessionManagerPort |
required |
Raises:
| Type | Description |
|---|---|
InvalidArgumentError
|
If the manager is None or doesn't implement SessionManagerPort |
Source code in archipy/adapters/postgres/sqlalchemy/session_manager_registry.py
get_async_manager
classmethod
¶
Get the asynchronous PostgreSQL session manager instance.
Lazily initializes a default AsyncPostgresSQlAlchemySessionManager if none has been set.
Returns:
| Name | Type | Description |
|---|---|---|
AsyncSessionManagerPort |
AsyncSessionManagerPort
|
The registered asynchronous session manager |
Raises:
| Type | Description |
|---|---|
DatabaseConnectionError
|
If there's an error initializing the session manager |
Source code in archipy/adapters/postgres/sqlalchemy/session_manager_registry.py
set_async_manager
classmethod
¶
Set a custom asynchronous session manager.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
manager
|
AsyncSessionManagerPort
|
An instance implementing AsyncSessionManagerPort |
required |
Raises:
| Type | Description |
|---|---|
InvalidArgumentError
|
If the manager is None or doesn't implement AsyncSessionManagerPort |
Source code in archipy/adapters/postgres/sqlalchemy/session_manager_registry.py
reset
classmethod
¶
Reset the registry to its initial state.
This method clears both registered managers, useful for testing.
Source code in archipy/adapters/postgres/sqlalchemy/session_manager_registry.py
options: show_root_toc_entry: false heading_level: 3
Adapters¶
Concrete PostgreSQL adapter built on top of the base SQLAlchemy adapter with PostgreSQL-specific configuration.
Classes:
| Name | Description |
|---|---|
PostgresSQLAlchemyAdapter |
Synchronous SQLAlchemy adapter for PostgreSQL. |
AsyncPostgresSQLAlchemyAdapter |
Asynchronous SQLAlchemy adapter for PostgreSQL. |
PostgresSQLAlchemyAdapter ¶
Synchronous SQLAlchemy adapter for PostgreSQL.
Inherits from BaseSQLAlchemyAdapter to provide PostgreSQL-specific session management and database operations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
orm_config
|
PostgresSQLAlchemyConfig | None
|
PostgreSQL-specific configuration. If None, uses global config. |
None
|
Source code in archipy/adapters/postgres/sqlalchemy/adapters.py
AsyncPostgresSQLAlchemyAdapter ¶
Asynchronous SQLAlchemy adapter for PostgreSQL.
Inherits from AsyncBaseSQLAlchemyAdapter to provide async PostgreSQL-specific session management and database operations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
orm_config
|
PostgresSQLAlchemyConfig | None
|
PostgreSQL-specific configuration. If None, uses global config. |
None
|
Source code in archipy/adapters/postgres/sqlalchemy/adapters.py
options: show_root_toc_entry: false heading_level: 3