29 lines
879 B
Python
29 lines
879 B
Python
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}'
|
|
|
|
model_config = SettingsConfigDict(env_file=".env")
|
|
|
|
|
|
settings = Settings()
|