diff --git a/backend/app/config.py b/backend/app/config.py index 4705d43..c946cf9 100644 --- a/backend/app/config.py +++ b/backend/app/config.py @@ -70,7 +70,8 @@ DB_NAME = _get_str("DB_NAME") # 完整连接字符串(直接从环境变量读取) DB_URI = _get_str("DB_URI") - +if not DB_URI and all([DB_HOST, DB_PORT, DB_USER, DB_PASSWORD, DB_NAME]): + DB_URI = f"postgresql://{DB_USER}:{DB_PASSWORD}@{DB_HOST}:{DB_PORT}/{DB_NAME}?sslmode=disable" # ========== 后端服务配置 ========== BACKEND_PORT = _get_int("BACKEND_PORT") diff --git a/backend/rag_core/config.py b/backend/rag_core/config.py index 1a1ccd3..adc6ee1 100644 --- a/backend/rag_core/config.py +++ b/backend/rag_core/config.py @@ -46,7 +46,8 @@ DB_NAME = _get_str("DB_NAME") # 完整连接字符串(直接从环境变量读取) DB_URI = _get_str("DB_URI") - +if not DB_URI and all([DB_HOST, DB_PORT, DB_USER, DB_PASSWORD, DB_NAME]): + DB_URI = f"postgresql://{DB_USER}:{DB_PASSWORD}@{DB_HOST}:{DB_PORT}/{DB_NAME}?sslmode=disable" # 文档存储 URI(直接从环境变量读取,默认同 DB_URI) DOCSTORE_URI = _get_str("DOCSTORE_URI") or DB_URI diff --git a/rag_indexer/config.py b/rag_indexer/config.py index 1ad0794..a4da69b 100644 --- a/rag_indexer/config.py +++ b/rag_indexer/config.py @@ -54,7 +54,8 @@ DB_NAME = _get_str("DB_NAME") # 完整连接字符串(直接从环境变量读取) DB_URI = _get_str("DB_URI") - +if not DB_URI and all([DB_HOST, DB_PORT, DB_USER, DB_PASSWORD, DB_NAME]): + DB_URI = f"postgresql://{DB_USER}:{DB_PASSWORD}@{DB_HOST}:{DB_PORT}/{DB_NAME}?sslmode=disable" # 文档存储 URI(直接从环境变量读取,默认同 DB_URI) DOCSTORE_URI = _get_str("DOCSTORE_URI") or DB_URI