Skip to content

Настройки БД

Bases: BaseSettings

Data.Rentgen backend database settings.

.. note::

You can pass here any extra option supported by
`SQLAlchemy Engine class <https://docs.sqlalchemy.org/en/20/core/engines.html#sqlalchemy.create_engine>`_,
even if it is not mentioned in documentation.

Examples

.. code-block:: bash

DATA_RENTGEN__DATABASE__URL=postgresql+asyncpg://postgres:postgres@localhost:5432/data_rentgen
# custom option passed directly to engine factory
DATA_RENTGEN__DATABASE__POOL_PRE_PING=True
Source code in data_rentgen/db/settings.py
10
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
class DatabaseSettings(BaseSettings):
    """Data.Rentgen backend database settings.

    .. note::

        You can pass here any extra option supported by
        `SQLAlchemy Engine class <https://docs.sqlalchemy.org/en/20/core/engines.html#sqlalchemy.create_engine>`_,
        even if it is not mentioned in documentation.

    Examples
    --------

    .. code-block:: bash

        DATA_RENTGEN__DATABASE__URL=postgresql+asyncpg://postgres:postgres@localhost:5432/data_rentgen
        # custom option passed directly to engine factory
        DATA_RENTGEN__DATABASE__POOL_PRE_PING=True
    """

    url: str = Field(
        description=textwrap.dedent(
            """
            Database connection URL.

            See `SQLAlchemy documentation <https://docs.sqlalchemy.org/en/20/core/engines.html#backend-specific-urls>`_

            .. warning:

                Only async drivers are supported, e.g. ``asyncpg``
            """,
        ),
    )

    model_config = SettingsConfigDict(env_prefix="DATA_RENTGEN__DATABASE__", env_nested_delimiter="__", extra="allow")

url = Field(description=(textwrap.dedent('\n Database connection URL.\n\n See `SQLAlchemy documentation <https://docs.sqlalchemy.org/en/20/core/engines.html#backend-specific-urls>`_\n\n .. warning:\n\n Only async drivers are supported, e.g. ``asyncpg``\n '))) class-attribute instance-attribute