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:
parent
771b5ba2f1
commit
46711d5172
|
@ -1,9 +1,9 @@
|
||||||
POSTGRES_PROTOCOL=postgresql+asyncpg
|
POSTGRES_DRIVER=postgresql+asyncpg
|
||||||
POSTGRES_HOST=db
|
POSTGRES_HOST=db
|
||||||
POSTGRES_PORT=5432
|
POSTGRES_PORT=5432
|
||||||
POSTGRES_USER=user
|
POSTGRES_USER=user
|
||||||
POSTGRES_PASSWORD=Qwe123
|
POSTGRES_PASSWORD=Qwe123
|
||||||
POSTGRES_NAME=api_db
|
POSTGRES_DB_NAME=api_db
|
||||||
|
|
||||||
NGINX_PORT=80
|
NGINX_PORT=80
|
||||||
API_HOST=0.0.0.0
|
API_HOST=0.0.0.0
|
||||||
|
|
|
@ -8,8 +8,8 @@ class DBSettings(pydantic_settings.BaseSettings):
|
||||||
"""Parent DB Settings Class."""
|
"""Parent DB Settings Class."""
|
||||||
|
|
||||||
# Connection settings
|
# Connection settings
|
||||||
protocol: str
|
driver: str
|
||||||
name: str
|
db_name: str
|
||||||
host: str
|
host: str
|
||||||
port: int
|
port: int
|
||||||
user: str
|
user: str
|
||||||
|
@ -27,12 +27,12 @@ class DBSettings(pydantic_settings.BaseSettings):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def dsn(self) -> str:
|
def dsn(self) -> str:
|
||||||
password = self.password.get_secret_value() if isinstance(self.password, pydantic.SecretStr) else self.password
|
password = self.password.get_secret_value()
|
||||||
return f"{self.protocol}://{self.user}:{password}@{self.host}:{self.port}"
|
return f"{self.driver}://{self.user}:{password}@{self.host}:{self.port}"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def dsn_as_safe_url(self) -> str:
|
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):
|
class PostgresSettings(DBSettings):
|
||||||
|
@ -45,8 +45,8 @@ class PostgresSettings(DBSettings):
|
||||||
extra="ignore",
|
extra="ignore",
|
||||||
)
|
)
|
||||||
|
|
||||||
protocol: str = "postgresql+asyncpg"
|
driver: str = "postgresql+asyncpg"
|
||||||
name: str = "database_name"
|
db_name: str = "database_name"
|
||||||
host: str = "localhost"
|
host: str = "localhost"
|
||||||
port: int = 5432
|
port: int = 5432
|
||||||
user: str = "app"
|
user: str = "app"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user