mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2025-12-15 14:22:55 +08:00
parent
46a0768a45
commit
582ad8c996
@ -357,7 +357,7 @@ SQLITE_CONFIG = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def get_config(db_url: str) -> dict:
|
def get_config() -> dict:
|
||||||
"""获取数据库配置"""
|
"""获取数据库配置"""
|
||||||
parsed = urlparse(BotConfig.db_url)
|
parsed = urlparse(BotConfig.db_url)
|
||||||
|
|
||||||
@ -404,7 +404,7 @@ def get_config(db_url: str) -> dict:
|
|||||||
config["connections"]["default"] = {
|
config["connections"]["default"] = {
|
||||||
"engine": "tortoise.backends.sqlite",
|
"engine": "tortoise.backends.sqlite",
|
||||||
"credentials": {
|
"credentials": {
|
||||||
"file_path": parsed.path[1:] or ":memory:",
|
"file_path": parsed.path or ":memory:",
|
||||||
},
|
},
|
||||||
**SQLITE_CONFIG,
|
**SQLITE_CONFIG,
|
||||||
}
|
}
|
||||||
@ -426,7 +426,7 @@ async def init():
|
|||||||
raise DbUrlIsNode("\n" + error.strip())
|
raise DbUrlIsNode("\n" + error.strip())
|
||||||
try:
|
try:
|
||||||
await Tortoise.init(
|
await Tortoise.init(
|
||||||
config=get_config(BotConfig.db_url),
|
config=get_config(),
|
||||||
)
|
)
|
||||||
if SCRIPT_METHOD:
|
if SCRIPT_METHOD:
|
||||||
db = Tortoise.get_connection("default")
|
db = Tortoise.get_connection("default")
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user