MCPcopy Create free account
hub / github.com/Tron521/codex-console-temp / check_database_connection

Function check_database_connection

src/database/init_db.py:50–63  ·  view source on GitHub ↗

检查数据库连接是否正常

(database_url: str = None)

Source from the content-addressed store, hash-verified

48
49
50def check_database_connection(database_url: str = None) -> bool:
51 """
52 检查数据库连接是否正常
53 """
54 try:
55 db_manager = init_database(database_url)
56 with db_manager.get_db() as db:
57 # 尝试执行一个简单的查询
58 db.execute("SELECT 1")
59 print("数据库连接正常")
60 return True
61 except Exception as e:
62 print(f"数据库连接失败: {e}")
63 return False
64
65
66if __name__ == "__main__":

Callers 1

init_db.pyFile · 0.85

Calls 2

init_databaseFunction · 0.85
get_dbMethod · 0.80

Tested by

no test coverage detected