Add table existence check for Oracle and PostgreSQL DB initialization
• Add Oracle table check on startup • Add PostgreSQL table check on startup • Use event loop for async DB operations • Ensure tables exist before DB operations
This commit is contained in:
@@ -447,6 +447,9 @@ class LightRAG:
|
||||
|
||||
# 初始化 OracleDB 对象
|
||||
oracle_db = OracleDB(dbconfig)
|
||||
# Check if DB tables exist, if not, tables will be created
|
||||
loop = always_get_an_event_loop()
|
||||
loop.run_until_complete(oracle_db.check_tables())
|
||||
|
||||
# 只对 Oracle 实现的存储类注入 db 对象
|
||||
if self.kv_storage == "OracleKVStorage":
|
||||
@@ -496,8 +499,11 @@ class LightRAG:
|
||||
|
||||
# 初始化 PostgreSQLDB 对象
|
||||
postgres_db = PostgreSQLDB(dbconfig)
|
||||
# Initialize and check tables
|
||||
loop = always_get_an_event_loop()
|
||||
loop.run_until_complete(postgres_db.initdb())
|
||||
# Check if DB tables exist, if not, tables will be created
|
||||
loop.run_until_complete(postgres_db.check_tables())
|
||||
|
||||
# 只对 PostgreSQL 实现的存储类注入 db 对象
|
||||
if self.kv_storage == "PGKVStorage":
|
||||
|
Reference in New Issue
Block a user