fastfood/fastfood/config.py

25 lines
662 B
Python

from pydantic_settings import BaseSettings, SettingsConfigDict
class Settings(BaseSettings):
DB_HOST: str = "localhost"
DB_PORT: int = 5432
DB_USER: str = "postrges"
DB_PASS: str = "postgres"
DB_NAME: str = "demo_db"
@property
def DATABASE_URL_asyncpg(self):
"""
Возвращает строку подключения к БД необходимую для SQLAlchemy
"""
return (
f"postgresql+asyncpg://{self.DB_USER}:{self.DB_PASS}"
f"@{self.DB_HOST}:{self.DB_PORT}/{self.DB_NAME}"
)
model_config = SettingsConfigDict(env_file=".env")
settings = Settings()