yangdx
commited on
Commit
·
3c340f7
1
Parent(s):
f8a75bc
Add table existence check for Oracle and PostgreSQL DB initialization
Browse files• 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
- lightrag/lightrag.py +6 -0
lightrag/lightrag.py
CHANGED
@@ -447,6 +447,9 @@ class LightRAG:
|
|
447 |
|
448 |
# 初始化 OracleDB 对象
|
449 |
oracle_db = OracleDB(dbconfig)
|
|
|
|
|
|
|
450 |
|
451 |
# 只对 Oracle 实现的存储类注入 db 对象
|
452 |
if self.kv_storage == "OracleKVStorage":
|
@@ -496,8 +499,11 @@ class LightRAG:
|
|
496 |
|
497 |
# 初始化 PostgreSQLDB 对象
|
498 |
postgres_db = PostgreSQLDB(dbconfig)
|
|
|
499 |
loop = always_get_an_event_loop()
|
500 |
loop.run_until_complete(postgres_db.initdb())
|
|
|
|
|
501 |
|
502 |
# 只对 PostgreSQL 实现的存储类注入 db 对象
|
503 |
if self.kv_storage == "PGKVStorage":
|
|
|
447 |
|
448 |
# 初始化 OracleDB 对象
|
449 |
oracle_db = OracleDB(dbconfig)
|
450 |
+
# Check if DB tables exist, if not, tables will be created
|
451 |
+
loop = always_get_an_event_loop()
|
452 |
+
loop.run_until_complete(oracle_db.check_tables())
|
453 |
|
454 |
# 只对 Oracle 实现的存储类注入 db 对象
|
455 |
if self.kv_storage == "OracleKVStorage":
|
|
|
499 |
|
500 |
# 初始化 PostgreSQLDB 对象
|
501 |
postgres_db = PostgreSQLDB(dbconfig)
|
502 |
+
# Initialize and check tables
|
503 |
loop = always_get_an_event_loop()
|
504 |
loop.run_until_complete(postgres_db.initdb())
|
505 |
+
# Check if DB tables exist, if not, tables will be created
|
506 |
+
loop.run_until_complete(postgres_db.check_tables())
|
507 |
|
508 |
# 只对 PostgreSQL 实现的存储类注入 db 对象
|
509 |
if self.kv_storage == "PGKVStorage":
|