PIbd-42_SSPR/settings.py

32 lines
1.0 KiB
Python
Raw Permalink Normal View History

from pydantic_settings import BaseSettings, SettingsConfigDict
class Settings(BaseSettings):
DB_USER: str
DB_PASSWORD: str
DB_HOST: str
DB_PORT: int
DB_NAME: str
DATABASE: str
POSTGRES_USER: str
POSTGRES_PASSWORD: str
CLICKHOUSE_USER: str
CLICKHOUSE_PASSWORD: str
@property
def db_url_asyncpg(self):
# 'postgresql+asyncpg://username:password@localhost:5432/database_name'
return f'postgresql+asyncpg://{self.DB_USER}:{self.DB_PASSWORD}@{self.DB_HOST}:{self.DB_PORT}/{self.DB_NAME}'
@property
def db_url_asyncpg_docker(self):
# 'postgresql+asyncpg://username:password@localhost:5432/database_name'
return f'postgresql+asyncpg://{self.POSTGRES_USER}:{self.POSTGRES_PASSWORD}@db:{self.DB_PORT}/{self.DATABASE}'
@property
def clickhouse_url(self):
return f'clickhouse://{self.CLICKHOUSE_USER}:{self.CLICKHOUSE_PASSWORD}@clickhouse:8123/{self.DATABASE}'
model_config = SettingsConfigDict(env_file=".env")
settings = Settings()