Closed kexue-z closed 1 year ago
与使用:nonebot-plugin-tortoise-orm 插件有冲突,覆盖了原先的数据库链接
改进建议:立即使用 nonebot-plugin-tortoise-orm
相关链接:https://github.com/kexue-z/nonebot-plugin-setu-now/issues/54#issuecomment-1685781949
``` PS D:\临时\bot\setu-test> nb run 使用 Python: D:\临时\bot\setu-test\.venv\Scripts\python.exe 08-21 15:13:35 [SUCCESS] nonebot | NoneBot is initializing... 08-21 15:13:35 [INFO] nonebot | Current Env: prod 08-21 15:13:35 [SUCCESS] nonebot | Succeeded to load plugin "nonebot_plugin_localstore" 08-21 15:13:35 [WARNING] nonebot_plugin_tortoise_orm | 没有设置数据库地址, 使用 sqlite:///C:\Users\****\AppData\Local\nonebot2\db.sqlite3 08-21 15:13:35 [SUCCESS] nonebot | Succeeded to load plugin "nonebot_plugin_tortoise_orm" 08-21 15:13:35 [SUCCESS] nonebot_plugin_tortoise_orm | 数据库: 添加模型: nonebot_plugin_setu_now.database 08-21 15:13:35 [SUCCESS] nonebot | Succeeded to load plugin "nonebot_plugin_setu_now" 08-21 15:13:37 [SUCCESS] nonebot | Succeeded to load plugin "nonebot_plugin_apscheduler" 08-21 15:13:37 [SUCCESS] nonebot | Succeeded to load plugin "nonebot_plugin_learning_chat" 08-21 15:13:37 [SUCCESS] nonebot | Running NoneBot... 08-21 15:13:37 [INFO] uvicorn | Started server process [19960] 08-21 15:13:37 [INFO] uvicorn | Waiting for application startup. 08-21 15:13:37 [SUCCESS] nonebot_plugin_tortoise_orm | 数据库: 连接成功 URL: sqlite:///C:\Users\****\AppData\Local\nonebot2\db.sqlite3 08-21 15:13:37 [INFO] nonebot_plugin_learning_chat | [群聊学习]数据库连接成功 08-21 15:13:37 [INFO] nonebot_plugin_apscheduler | Scheduler Started 08-21 15:13:37 [INFO] uvicorn | Application startup complete. 08-21 15:13:37 [INFO] uvicorn | Uvicorn running on http://127.0.0.1:8080 (Press CTRL+C to quit) 08-21 15:13:38 [INFO] uvicorn | ('127.0.0.1', 58662) - "WebSocket /onebot/v11/ws" [accepted] 08-21 15:13:38 [INFO] nonebot | OneBot V11 | Bot 1234connected 08-21 15:13:38 [INFO] websockets | connection open 08-21 15:14:11 [SUCCESS] nonebot | OneBot V11 1234| [message.group.normal]: Message 10004 from 1234@[群:1234] '色图' 08-21 15:14:11 [INFO] nonebot | Event will be handled by Matcher(type='message', module=nonebot_plugin_setu_now) 08-21 15:14:11 [INFO] nonebot | Matcher(type='message', module=nonebot_plugin_setu_now) running complete 08-21 15:14:11 [ERROR] nonebot | Running Matcher(type='message', module=nonebot_plugin_setu_now) failed. Traceback (most recent call last): File "D:\临时\bot\setu-test\.venv\lib\site-packages\tortoise\backends\sqlite\client.py", line 34, in translate_exceptions_ return await func(self, query, *args) File "D:\临时\bot\setu-test\.venv\lib\site-packages\tortoise\backends\sqlite\client.py", line 141, in execute_query rows = await connection.execute_fetchall(query, values) File "D:\临时\bot\setu-test\.venv\lib\site-packages\aiosqlite\core.py", line 203, in execute_fetchall return await self._execute(self._execute_fetchall, sql, parameters) File "D:\临时\bot\setu-test\.venv\lib\site-packages\aiosqlite\core.py", line 129, in _execute return await future File "D:\临时\bot\setu-test\.venv\lib\site-packages\aiosqlite\core.py", line 102, in run result = function() File "D:\临时\bot\setu-test\.venv\lib\site-packages\aiosqlite\core.py", line 81, in _execute_fetchall cursor = self._conn.execute(sql, parameters) sqlite3.OperationalError: no such table: white_list During handling of the above exception, another exception occurred: Traceback (most recent call last): File "", line 15, in File "D:\临时\bot\setu-test\.venv\lib\site-packages\nonebot\__init__.py", line 333, in run get_driver().run(*args, **kwargs) File "D:\临时\bot\setu-test\.venv\lib\site-packages\nonebot\drivers\fastapi.py", line 199, in run uvicorn.run( File "D:\临时\bot\setu-test\.venv\lib\site-packages\uvicorn\main.py", line 587, in run server.run() File "D:\临时\bot\setu-test\.venv\lib\site-packages\uvicorn\server.py", line 61, in run return asyncio.run(self.serve(sockets=sockets)) File "C:\Users\****\AppData\Local\miniconda3\lib\asyncio\runners.py", line 44, in run return loop.run_until_complete(main) File "C:\Users\****\AppData\Local\miniconda3\lib\asyncio\base_events.py", line 636, in run_until_complete self.run_forever() File "C:\Users\****\AppData\Local\miniconda3\lib\asyncio\windows_events.py", line 321, in run_forever super().run_forever() File "C:\Users\****\AppData\Local\miniconda3\lib\asyncio\base_events.py", line 603, in run_forever self._run_once() File "C:\Users\****\AppData\Local\miniconda3\lib\asyncio\base_events.py", line 1906, in _run_once handle._run() File "C:\Users\****\AppData\Local\miniconda3\lib\asyncio\events.py", line 80, in _run self._context.run(self._callback, *self._args) File "D:\临时\bot\setu-test\.venv\lib\site-packages\nonebot\message.py", line 467, in check_and_run_matcher await _run_matcher( > File "D:\临时\bot\setu-test\.venv\lib\site-packages\nonebot\message.py", line 419, in _run_matcher await matcher.run(bot, event, state, stack, dependency_cache) File "D:\临时\bot\setu-test\.venv\lib\site-packages\nonebot\internal\matcher\matcher.py", line 759, in run await self.simple_run(bot, event, state, stack, dependency_cache) File "D:\临时\bot\setu-test\.venv\lib\site-packages\nonebot\internal\matcher\matcher.py", line 734, in simple_run await handler( File "D:\临时\bot\setu-test\.venv\lib\site-packages\nonebot\dependencies\__init__.py", line 104, in __call__ values = await self.solve(**kwargs) File "D:\临时\bot\setu-test\.venv\lib\site-packages\nonebot\dependencies\__init__.py", line 220, in solve values = await asyncio.gather( File "D:\临时\bot\setu-test\.venv\lib\site-packages\nonebot\dependencies\__init__.py", line 209, in _solve_field value = await cast(Param, field.field_info)._solve(**params) File "D:\临时\bot\setu-test\.venv\lib\site-packages\nonebot\internal\params.py", line 166, in _solve return await task File "D:\临时\bot\setu-test\.venv\lib\site-packages\nonebot_plugin_setu_now\r18_whitelist.py", line 15, in get_group_white_list_record res = await GroupWhiteListRecord.get_or_none(group_id=event.group_id) File "D:\临时\bot\setu-test\.venv\lib\site-packages\tortoise\queryset.py", line 1008, in _execute instance_list = await self._db.executor_class( File "D:\临时\bot\setu-test\.venv\lib\site-packages\tortoise\backends\base\executor.py", line 131, in execute_select _, raw_results = await self.db.execute_query(query.get_sql()) File "D:\临时\bot\setu-test\.venv\lib\site-packages\tortoise\backends\sqlite\client.py", line 36, in translate_exceptions_ raise OperationalError(exc) tortoise.exceptions.OperationalError: no such table: white_list 08-21 15:14:16 [INFO] uvicorn | Shutting down 08-21 15:14:16 [WARNING] nonebot | OneBot V11 | WebSocket for Bot 1234closed by peer 08-21 15:14:16 [INFO] websockets | connection closed 08-21 15:14:16 [INFO] uvicorn | Waiting for application shutdown. 08-21 15:14:16 [SUCCESS] nonebot_plugin_tortoise_orm | 数据库: 断开链接 08-21 15:14:16 [INFO] nonebot_plugin_learning_chat | [群聊学习]数据库断开连接成功 08-21 15:14:16 [INFO] nonebot_plugin_apscheduler | Scheduler Shutdown 08-21 15:14:16 [INFO] uvicorn | Application shutdown complete. 08-21 15:14:16 [INFO] uvicorn | Finished server process [19960] ```
与使用:nonebot-plugin-tortoise-orm 插件有冲突,覆盖了原先的数据库链接
改进建议:立即使用 nonebot-plugin-tortoise-orm
相关链接:https://github.com/kexue-z/nonebot-plugin-setu-now/issues/54#issuecomment-1685781949
错误日志:
``` PS D:\临时\bot\setu-test> nb run 使用 Python: D:\临时\bot\setu-test\.venv\Scripts\python.exe 08-21 15:13:35 [SUCCESS] nonebot | NoneBot is initializing... 08-21 15:13:35 [INFO] nonebot | Current Env: prod 08-21 15:13:35 [SUCCESS] nonebot | Succeeded to load plugin "nonebot_plugin_localstore" 08-21 15:13:35 [WARNING] nonebot_plugin_tortoise_orm | 没有设置数据库地址, 使用 sqlite:///C:\Users\****\AppData\Local\nonebot2\db.sqlite3 08-21 15:13:35 [SUCCESS] nonebot | Succeeded to load plugin "nonebot_plugin_tortoise_orm" 08-21 15:13:35 [SUCCESS] nonebot_plugin_tortoise_orm | 数据库: 添加模型: nonebot_plugin_setu_now.database 08-21 15:13:35 [SUCCESS] nonebot | Succeeded to load plugin "nonebot_plugin_setu_now" 08-21 15:13:37 [SUCCESS] nonebot | Succeeded to load plugin "nonebot_plugin_apscheduler" 08-21 15:13:37 [SUCCESS] nonebot | Succeeded to load plugin "nonebot_plugin_learning_chat" 08-21 15:13:37 [SUCCESS] nonebot | Running NoneBot... 08-21 15:13:37 [INFO] uvicorn | Started server process [19960] 08-21 15:13:37 [INFO] uvicorn | Waiting for application startup. 08-21 15:13:37 [SUCCESS] nonebot_plugin_tortoise_orm | 数据库: 连接成功 URL: sqlite:///C:\Users\****\AppData\Local\nonebot2\db.sqlite3 08-21 15:13:37 [INFO] nonebot_plugin_learning_chat | [群聊学习]数据库连接成功
08-21 15:13:37 [INFO] nonebot_plugin_apscheduler | Scheduler Started
08-21 15:13:37 [INFO] uvicorn | Application startup complete.
08-21 15:13:37 [INFO] uvicorn | Uvicorn running on http://127.0.0.1:8080 (Press CTRL+C to quit)
08-21 15:13:38 [INFO] uvicorn | ('127.0.0.1', 58662) - "WebSocket /onebot/v11/ws" [accepted]
08-21 15:13:38 [INFO] nonebot | OneBot V11 | Bot 1234connected
08-21 15:13:38 [INFO] websockets | connection open
08-21 15:14:11 [SUCCESS] nonebot | OneBot V11 1234| [message.group.normal]: Message 10004 from 1234@[群:1234] '色图'
08-21 15:14:11 [INFO] nonebot | Event will be handled by Matcher(type='message', module=nonebot_plugin_setu_now)
08-21 15:14:11 [INFO] nonebot | Matcher(type='message', module=nonebot_plugin_setu_now) running complete
08-21 15:14:11 [ERROR] nonebot | Running Matcher(type='message', module=nonebot_plugin_setu_now) failed.
Traceback (most recent call last):
File "D:\临时\bot\setu-test\.venv\lib\site-packages\tortoise\backends\sqlite\client.py", line 34, in translate_exceptions_
return await func(self, query, *args)
File "D:\临时\bot\setu-test\.venv\lib\site-packages\tortoise\backends\sqlite\client.py", line 141, in execute_query
rows = await connection.execute_fetchall(query, values)
File "D:\临时\bot\setu-test\.venv\lib\site-packages\aiosqlite\core.py", line 203, in execute_fetchall
return await self._execute(self._execute_fetchall, sql, parameters)
File "D:\临时\bot\setu-test\.venv\lib\site-packages\aiosqlite\core.py", line 129, in _execute
return await future
File "D:\临时\bot\setu-test\.venv\lib\site-packages\aiosqlite\core.py", line 102, in run
result = function()
File "D:\临时\bot\setu-test\.venv\lib\site-packages\aiosqlite\core.py", line 81, in _execute_fetchall
cursor = self._conn.execute(sql, parameters)
sqlite3.OperationalError: no such table: white_list
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "", line 15, in
File "D:\临时\bot\setu-test\.venv\lib\site-packages\nonebot\__init__.py", line 333, in run
get_driver().run(*args, **kwargs)
File "D:\临时\bot\setu-test\.venv\lib\site-packages\nonebot\drivers\fastapi.py", line 199, in run
uvicorn.run(
File "D:\临时\bot\setu-test\.venv\lib\site-packages\uvicorn\main.py", line 587, in run
server.run()
File "D:\临时\bot\setu-test\.venv\lib\site-packages\uvicorn\server.py", line 61, in run
return asyncio.run(self.serve(sockets=sockets))
File "C:\Users\****\AppData\Local\miniconda3\lib\asyncio\runners.py", line 44, in run
return loop.run_until_complete(main)
File "C:\Users\****\AppData\Local\miniconda3\lib\asyncio\base_events.py", line 636, in run_until_complete
self.run_forever()
File "C:\Users\****\AppData\Local\miniconda3\lib\asyncio\windows_events.py", line 321, in run_forever
super().run_forever()
File "C:\Users\****\AppData\Local\miniconda3\lib\asyncio\base_events.py", line 603, in run_forever
self._run_once()
File "C:\Users\****\AppData\Local\miniconda3\lib\asyncio\base_events.py", line 1906, in _run_once
handle._run()
File "C:\Users\****\AppData\Local\miniconda3\lib\asyncio\events.py", line 80, in _run
self._context.run(self._callback, *self._args)
File "D:\临时\bot\setu-test\.venv\lib\site-packages\nonebot\message.py", line 467, in check_and_run_matcher
await _run_matcher(
> File "D:\临时\bot\setu-test\.venv\lib\site-packages\nonebot\message.py", line 419, in _run_matcher
await matcher.run(bot, event, state, stack, dependency_cache)
File "D:\临时\bot\setu-test\.venv\lib\site-packages\nonebot\internal\matcher\matcher.py", line 759, in run
await self.simple_run(bot, event, state, stack, dependency_cache)
File "D:\临时\bot\setu-test\.venv\lib\site-packages\nonebot\internal\matcher\matcher.py", line 734, in simple_run
await handler(
File "D:\临时\bot\setu-test\.venv\lib\site-packages\nonebot\dependencies\__init__.py", line 104, in __call__
values = await self.solve(**kwargs)
File "D:\临时\bot\setu-test\.venv\lib\site-packages\nonebot\dependencies\__init__.py", line 220, in solve
values = await asyncio.gather(
File "D:\临时\bot\setu-test\.venv\lib\site-packages\nonebot\dependencies\__init__.py", line 209, in _solve_field
value = await cast(Param, field.field_info)._solve(**params)
File "D:\临时\bot\setu-test\.venv\lib\site-packages\nonebot\internal\params.py", line 166, in _solve
return await task
File "D:\临时\bot\setu-test\.venv\lib\site-packages\nonebot_plugin_setu_now\r18_whitelist.py", line 15, in get_group_white_list_record
res = await GroupWhiteListRecord.get_or_none(group_id=event.group_id)
File "D:\临时\bot\setu-test\.venv\lib\site-packages\tortoise\queryset.py", line 1008, in _execute
instance_list = await self._db.executor_class(
File "D:\临时\bot\setu-test\.venv\lib\site-packages\tortoise\backends\base\executor.py", line 131, in execute_select
_, raw_results = await self.db.execute_query(query.get_sql())
File "D:\临时\bot\setu-test\.venv\lib\site-packages\tortoise\backends\sqlite\client.py", line 36, in translate_exceptions_
raise OperationalError(exc)
tortoise.exceptions.OperationalError: no such table: white_list
08-21 15:14:16 [INFO] uvicorn | Shutting down
08-21 15:14:16 [WARNING] nonebot | OneBot V11 | WebSocket for Bot 1234closed by peer
08-21 15:14:16 [INFO] websockets | connection closed
08-21 15:14:16 [INFO] uvicorn | Waiting for application shutdown.
08-21 15:14:16 [SUCCESS] nonebot_plugin_tortoise_orm | 数据库: 断开链接
08-21 15:14:16 [INFO] nonebot_plugin_learning_chat | [群聊学习]数据库断开连接成功
08-21 15:14:16 [INFO] nonebot_plugin_apscheduler | Scheduler Shutdown
08-21 15:14:16 [INFO] uvicorn | Application shutdown complete.
08-21 15:14:16 [INFO] uvicorn | Finished server process [19960]
```