2024-10-04 17:19:46 +04:00
|
|
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
|
|
|
|
|
|
class Settings(BaseSettings):
|
2024-10-17 13:51:33 +04:00
|
|
|
DB_USER: str
|
|
|
|
DB_PASSWORD: str
|
|
|
|
DB_HOST: str
|
|
|
|
DB_PORT: int
|
|
|
|
DB_NAME: str
|
2024-10-04 17:19:46 +04:00
|
|
|
DATABASE: str
|
|
|
|
POSTGRES_USER: str
|
|
|
|
POSTGRES_PASSWORD: str
|
|
|
|
CLICKHOUSE_USER: str
|
|
|
|
CLICKHOUSE_PASSWORD: str
|
|
|
|
|
2024-10-17 13:51:33 +04:00
|
|
|
@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}'
|
|
|
|
|
2024-10-25 02:02:31 +04:00
|
|
|
@property
|
|
|
|
def clickhouse_url(self):
|
|
|
|
return f'clickhouse://{self.CLICKHOUSE_USER}:{self.CLICKHOUSE_PASSWORD}@clickhouse:8123/{self.DATABASE}'
|
2024-10-04 17:19:46 +04:00
|
|
|
|
2024-10-25 02:02:31 +04:00
|
|
|
model_config = SettingsConfigDict(env_file=".env")
|
2024-10-04 17:19:46 +04:00
|
|
|
|
|
|
|
settings = Settings()
|