Archived
1
0
Fork 0
This repository has been archived on 2024-04-26. You can view files and clone it, but cannot push or open issues or pull requests.
akari-bot/database/orm.py
2021-08-25 00:49:19 +08:00

18 lines
477 B
Python

from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from config import Config
from database.tables import *
DB_LINK = Config('db_path')
class DBSession:
def __init__(self):
self.engine = engine = create_engine(DB_LINK)
Base.metadata.create_all(bind=engine, checkfirst=True)
self.Session = sessionmaker()
self.Session.configure(bind=self.engine)
@property
def session(self):
return self.Session()