🐛 修复sqlite连接问题 (#1979)

* 🚑 修复sqlite连接问题

* 🔧 移除db_url参数以简化数据库配置获取逻辑
This commit is contained in:
HibiKier 2025-07-14 22:59:56 +08:00 committed by GitHub
parent 46a0768a45
commit 582ad8c996
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -357,7 +357,7 @@ SQLITE_CONFIG = {
}
def get_config(db_url: str) -> dict:
def get_config() -> dict:
"""获取数据库配置"""
parsed = urlparse(BotConfig.db_url)
@ -404,7 +404,7 @@ def get_config(db_url: str) -> dict:
config["connections"]["default"] = {
"engine": "tortoise.backends.sqlite",
"credentials": {
"file_path": parsed.path[1:] or ":memory:",
"file_path": parsed.path or ":memory:",
},
**SQLITE_CONFIG,
}
@ -426,7 +426,7 @@ async def init():
raise DbUrlIsNode("\n" + error.strip())
try:
await Tortoise.init(
config=get_config(BotConfig.db_url),
config=get_config(),
)
if SCRIPT_METHOD:
db = Tortoise.get_connection("default")