Archived
1
0
Fork 0
This repository has been archived on 2024-02-17. You can view files and clone it, but cannot push or open issues or pull requests.
teleexit/db/__init__.py

17 lines
476 B
Python
Raw Normal View History

2020-11-07 15:15:44 +01:00
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.declarative import declarative_base
from bot import config
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.User import User
Base.metadata.create_all(engine)