updated postgres and mongo updated

This commit is contained in:
2025-04-20 14:21:13 +03:00
parent 71822681f2
commit cc19cb7e6d
85 changed files with 6090 additions and 1986 deletions

View File

@@ -1,3 +1,4 @@
import os
from pydantic_settings import BaseSettings, SettingsConfigDict
@@ -6,19 +7,25 @@ class Configs(BaseSettings):
MongoDB configuration settings.
"""
USER: str = ""
PASSWORD: str = ""
HOST: str = ""
PORT: int = 0
DB: str = ""
ENGINE: str = ""
# MongoDB connection settings
ENGINE: str = "mongodb"
USERNAME: str = "appuser" # Application user
PASSWORD: str = "apppassword" # Application password
HOST: str = "10.10.2.13"
PORT: int = 27017
DB: str = "appdb" # The application database
AUTH_DB: str = "appdb" # Authentication is done against admin database
@property
def url(self):
"""Generate the database URL."""
return f"{self.ENGINE}://{self.USER}:{self.PASSWORD}@{self.HOST}:{self.PORT}/{self.DB}?retryWrites=true&w=majority"
"""Generate the database URL.
mongodb://{MONGO_USERNAME}:{MONGO_PASSWORD}@{MONGO_HOST}:{MONGO_PORT}/{DB}?authSource={MONGO_AUTH_DB}
"""
# Include the database name in the URI
return f"{self.ENGINE}://{self.USERNAME}:{self.PASSWORD}@{self.HOST}:{self.PORT}/{self.DB}?authSource={self.DB}"
model_config = SettingsConfigDict(env_prefix="MONGO_")
model_config = SettingsConfigDict(env_prefix="_MONGO_")
mongo_configs = Configs() # singleton instance of the MONGODB configuration settings
# Create a singleton instance of the MongoDB configuration settings
mongo_configs = Configs()