Change session usage to on use basis.

This commit is contained in:
alwayscompiling
2022-12-06 22:28:53 -05:00
parent 296e14f0f6
commit 3446ce9ca2
11 changed files with 357 additions and 306 deletions
+20
View File
@@ -0,0 +1,20 @@
"""
Simple file to set up the sqlalchemy connection to database.
"""
from sqlalchemy import create_engine
from sqlalchemy.ext.automap import automap_base
# pylint: disable=import-error
from utilities import config
# connect with sql alchemy and autoload schema
url = f"mysql://{config.SQL_USER}:{config.SQL_PASS}@{config.SQL_HOST}/{config.SQL_DB}"
engine = create_engine(url)
Base = automap_base()
Base.prepare(autoload_with=engine)
# define the classes
Guild = Base.classes.Guilds
CategoryGroup = Base.classes.CategoryGroups
Category = Base.classes.Categories
Score = Base.classes.Scores