PIbd-42_SSPR/db/config.py

19 lines
509 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
@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}'
model_config = SettingsConfigDict(env_file='../.env')
settings = Settings()