from pydantic import BaseModel from pydantic import PostgresDsn # from pydantic import MariaDBDsn # from pydantic import MySQLDsn from pydantic_settings import ( BaseSettings, SettingsConfigDict, ) from pathlib import Path BASE_DIR = Path(__file__).parent class RunConfig(BaseModel): host: str = "0.0.0.0" port: int = 8000 reload: bool = True class ApiPrefix(BaseModel): users: str = "/api/users" isp: str = "/api/isp" isp_connections: str = "/api/isp_connections" class WebPrefix(BaseModel): isp: str = "/web/isp" settings: str = "/web/settings" isp_connections: str = "/web/isp_connections" start: str = "/web" class DatabaseConfig(BaseModel): url: PostgresDsn echo: bool = False echo_pool: bool = False pool_size: int = 50 max_overflow: int = 10 naming_convention: dict[str, str] = { "ix": "ix_%(column_0_label)s", "uq": "uq_%(table_name)s_%(column_0_N_name)s", "ck": "ck_%(table_name)s_%(constraint_name)s", "fk": "fk_%(table_name)s_%(column_0_name)s_%(referred_table_name)s", "pk": "pk_%(table_name)s", } class Settings(BaseSettings): model_config = SettingsConfigDict( env_file=(BASE_DIR / ".env-template", BASE_DIR / ".env"), case_sensitive=False, env_nested_delimiter="__", env_prefix="SIPI_CONFIG__", ) run: RunConfig = RunConfig() api: ApiPrefix = ApiPrefix() web: WebPrefix = WebPrefix() db: DatabaseConfig settings = Settings()