fix 数据库连接复用

This commit is contained in:
jxxghp
2023-08-22 08:13:44 +08:00
parent a202b5efdd
commit 781de29591
10 changed files with 57 additions and 40 deletions

View File

@ -5,6 +5,7 @@ from typing import Any, List, Dict, Tuple
from app.chain import ChainBase
from app.core.config import settings
from app.core.event import EventManager
from app.db import SessionLocal
from app.db.models import Base
from app.db.plugindata_oper import PluginDataOper
from app.db.systemconfig_oper import SystemConfigOper
@ -37,10 +38,12 @@ class _PluginBase(metaclass=ABCMeta):
plugin_desc: str = ""
def __init__(self):
# 数据库连接
self.db = SessionLocal()
# 插件数据
self.plugindata = PluginDataOper()
self.plugindata = PluginDataOper(self.db)
# 处理链
self.chain = PluginChian()
self.chain = PluginChian(self.db)
# 系统配置
self.systemconfig = SystemConfigOper()
# 系统消息