fix dboper

This commit is contained in:
jxxghp
2023-06-15 07:12:59 +08:00
parent 7506f39258
commit ab4895ff85
13 changed files with 106 additions and 89 deletions

View File

@ -1,5 +1,5 @@
from sqlalchemy import create_engine, QueuePool
from sqlalchemy.orm import sessionmaker
from sqlalchemy.orm import sessionmaker, Session
from app.core.config import settings
@ -27,3 +27,15 @@ def get_db():
finally:
if db:
db.close()
class DbOper:
_db: Session = None
def __init__(self, _db=SessionLocal()):
self._db = _db
def __del__(self):
if self._db:
self._db.close()