sipi-web/sipi-app/core/config.py

43 lines
852 B
Python
Raw Normal View History

2024-07-11 16:01:26 +00:00
from pydantic import BaseModel
from pydantic import PostgresDsn
from pydantic import MariaDBDsn
from pydantic import MySQLDsn
from pydantic_settings import (
BaseSettings,
SettingsConfigDict,
)
class RunConfig(BaseModel):
host: str = '0.0.0.0'
port: int = 8000
reload: bool = True
class ApiPrefix(BaseModel):
prefix: str = '/api'
class DatabaseConfig(BaseModel):
url: PostgresDsn
echo: bool = False
echo_pool: bool = False
pool_size: int = 50
max_overflow: int = 10
class Settings(BaseSettings):
model_config = SettingsConfigDict(
2024-07-11 18:01:46 +00:00
env_file=('.env-template', '.env'),
2024-07-11 16:01:26 +00:00
case_sensitive=False,
2024-07-11 18:01:46 +00:00
env_nested_delimiter='__',
env_prefix='SIPI_CONFIG__',
2024-07-11 16:01:26 +00:00
)
run: RunConfig = RunConfig()
api: ApiPrefix = ApiPrefix()
db: DatabaseConfig
settings = Settings()
2024-07-11 18:01:46 +00:00