45 lines
1.2 KiB
Python
45 lines
1.2 KiB
Python
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
|
|
|
|
class Configs(BaseSettings):
|
|
"""
|
|
Postgresql configuration settings.
|
|
POSTGRES_USER=postgres
|
|
POSTGRES_PASSWORD=password
|
|
POSTGRES_DB=postgres
|
|
POSTGRES_HOST=10.10.2.14
|
|
POSTGRES_PORT=5432
|
|
POSTGRES_ENGINE=postgresql+psycopg2
|
|
POSTGRES_POOL_PRE_PING=True
|
|
POSTGRES_POOL_SIZE=20
|
|
POSTGRES_MAX_OVERFLOW=10
|
|
POSTGRES_POOL_RECYCLE=600
|
|
POSTGRES_POOL_TIMEOUT=30
|
|
POSTGRES_ECHO=True
|
|
# "postgresql+psycopg2://postgres:password@10.10.2.14:5432/postgres"
|
|
"""
|
|
|
|
DB: str = ""
|
|
USER: str = ""
|
|
PASSWORD: str = ""
|
|
HOST: str = ""
|
|
PORT: int = 0
|
|
ENGINE: str = "postgresql+psycopg2"
|
|
POOL_PRE_PING: bool = True
|
|
POOL_SIZE: int = 20
|
|
MAX_OVERFLOW: int = 10
|
|
POOL_RECYCLE: int = 600
|
|
POOL_TIMEOUT: int = 30
|
|
ECHO: bool = True
|
|
|
|
@property
|
|
def url(self):
|
|
"""Generate the database URL."""
|
|
return f"{self.ENGINE}://{self.USER}:{self.PASSWORD}@{self.HOST}:{self.PORT}/{self.DB}"
|
|
|
|
model_config = SettingsConfigDict(env_prefix="POSTGRES_")
|
|
|
|
|
|
# singleton instance of the POSTGRESQL configuration settings
|
|
postgres_configs = Configs()
|