30 lines
764 B
Python
30 lines
764 B
Python
from functools import lru_cache
|
|
|
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
model_config = SettingsConfigDict(env_file=".env", extra="ignore")
|
|
|
|
app_name: str = "Pitopn"
|
|
secret_key: str = "dev-secret"
|
|
debug: bool = False
|
|
|
|
postgres_user: str = "pitopn"
|
|
postgres_password: str = "pitopn"
|
|
postgres_db: str = "pitopn"
|
|
postgres_host: str = "localhost"
|
|
postgres_port: int = 5432
|
|
|
|
@property
|
|
def database_url(self) -> str:
|
|
return (
|
|
f"postgresql+psycopg2://{self.postgres_user}:{self.postgres_password}"
|
|
f"@{self.postgres_host}:{self.postgres_port}/{self.postgres_db}"
|
|
)
|
|
|
|
|
|
@lru_cache
|
|
def get_settings() -> Settings:
|
|
return Settings()
|