| default='', | default='', | ||||
| ) | ) | ||||
| DB_EXTRAS: str = Field( | |||||
| description='db extras options. Example: keepalives_idle=60&keepalives=1', | |||||
| default='', | |||||
| ) | |||||
| SQLALCHEMY_DATABASE_URI_SCHEME: str = Field( | SQLALCHEMY_DATABASE_URI_SCHEME: str = Field( | ||||
| description='db uri scheme', | description='db uri scheme', | ||||
| default='postgresql', | default='postgresql', | ||||
| @computed_field | @computed_field | ||||
| @property | @property | ||||
| def SQLALCHEMY_DATABASE_URI(self) -> str: | def SQLALCHEMY_DATABASE_URI(self) -> str: | ||||
| db_extras = f"?client_encoding={self.DB_CHARSET}" if self.DB_CHARSET else "" | |||||
| db_extras = ( | |||||
| f"{self.DB_EXTRAS}&client_encoding={self.DB_CHARSET}" | |||||
| if self.DB_CHARSET | |||||
| else self.DB_EXTRAS | |||||
| ).strip("&") | |||||
| db_extras = f"?{db_extras}" if db_extras else "" | |||||
| return (f"{self.SQLALCHEMY_DATABASE_URI_SCHEME}://" | return (f"{self.SQLALCHEMY_DATABASE_URI_SCHEME}://" | ||||
| f"{self.DB_USERNAME}:{self.DB_PASSWORD}@{self.DB_HOST}:{self.DB_PORT}/{self.DB_DATABASE}" | f"{self.DB_USERNAME}:{self.DB_PASSWORD}@{self.DB_HOST}:{self.DB_PORT}/{self.DB_DATABASE}" | ||||
| f"{db_extras}") | f"{db_extras}") | ||||
| default=False, | default=False, | ||||
| ) | ) | ||||
| SQLALCHEMY_ECHO: bool = Field( | |||||
| SQLALCHEMY_ECHO: bool | str = Field( | |||||
| description='whether to enable SqlAlchemy echo', | description='whether to enable SqlAlchemy echo', | ||||
| default=False, | default=False, | ||||
| ) | ) |