from dataclasses import dataclass @dataclass(frozen=True) class DBSettings: pg_user: str pg_pass: str pg_host: str pg_port: int pg_db: str @property def get_db_url(self) -> str: return "postgresql+psycopg2://{}:{}@{}:{}/{}".format( self.pg_user, self.pg_pass, self.pg_host, self.pg_port, self.pg_db, )