1
0
mirror of https://github.com/ijaric/voice_assistant.git synced 2025-05-24 14:33:26 +00:00

fix: db settings improvements

This commit is contained in:
Artem Litvinov 2023-09-29 17:13:35 +01:00
parent 771b5ba2f1
commit 46711d5172
2 changed files with 9 additions and 9 deletions

View File

@ -1,9 +1,9 @@
POSTGRES_PROTOCOL=postgresql+asyncpg
POSTGRES_DRIVER=postgresql+asyncpg
POSTGRES_HOST=db
POSTGRES_PORT=5432
POSTGRES_USER=user
POSTGRES_PASSWORD=Qwe123
POSTGRES_NAME=api_db
POSTGRES_DB_NAME=api_db
NGINX_PORT=80
API_HOST=0.0.0.0

View File

@ -8,8 +8,8 @@ class DBSettings(pydantic_settings.BaseSettings):
"""Parent DB Settings Class."""
# Connection settings
protocol: str
name: str
driver: str
db_name: str
host: str
port: int
user: str
@ -27,12 +27,12 @@ class DBSettings(pydantic_settings.BaseSettings):
@property
def dsn(self) -> str:
password = self.password.get_secret_value() if isinstance(self.password, pydantic.SecretStr) else self.password
return f"{self.protocol}://{self.user}:{password}@{self.host}:{self.port}"
password = self.password.get_secret_value()
return f"{self.driver}://{self.user}:{password}@{self.host}:{self.port}"
@property
def dsn_as_safe_url(self) -> str:
return f"{self.protocol}://{self.user}:***@{self.host}:{self.port}"
return f"{self.driver}://{self.user}:***@{self.host}:{self.port}"
class PostgresSettings(DBSettings):
@ -45,8 +45,8 @@ class PostgresSettings(DBSettings):
extra="ignore",
)
protocol: str = "postgresql+asyncpg"
name: str = "database_name"
driver: str = "postgresql+asyncpg"
db_name: str = "database_name"
host: str = "localhost"
port: int = 5432
user: str = "app"