diff --git a/db/__init__.py b/db/__init__.py index 1741487..96eaebb 100644 --- a/db/__init__.py +++ b/db/__init__.py @@ -2,7 +2,11 @@ from administrator.config import config from sqlalchemy import create_engine from sqlalchemy.orm import sessionmaker from sqlalchemy.ext.declarative import declarative_base -engine = create_engine(config.get("db")) +db = config.get("db") +args = {"pool_pre_ping": True, "pool_recycle": 3600} +if not db.startswith("sqlite:"): + args.update({"pool_size": 0, "max_overflow": -1}) +engine = create_engine(db, **args) Session = sessionmaker(bind=engine) Base = declarative_base() from db.Task import Task diff --git a/extensions/rorec.py b/extensions/rorec.py index 30f8419..add3718 100644 --- a/extensions/rorec.py +++ b/extensions/rorec.py @@ -87,6 +87,7 @@ class RoRec(commands.Cog): s = db.Session() s.add(r) s.commit() + s.close() await ctx.message.add_reaction("\U0001f44d") @rorec.group("edit", pass_context=True)