Create new python file for handling sqlalchemy. Removes circular import.
This commit is contained in:
@@ -8,9 +8,6 @@ import sys
|
||||
|
||||
import nextcord
|
||||
from nextcord.ext import commands
|
||||
from sqlalchemy import create_engine
|
||||
from sqlalchemy.ext.automap import automap_base
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
import config
|
||||
from classes.submission import SubmissionMap
|
||||
@@ -21,20 +18,6 @@ handler = logging.FileHandler(filename="nextcord.log", encoding="utf-8", mode="w
|
||||
handler.setFormatter(logging.Formatter("%(asctime)s:%(levelname)s:%(name)s: %(message)s"))
|
||||
logger.addHandler(handler)
|
||||
|
||||
# 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)
|
||||
connection = engine.connect()
|
||||
Base = automap_base()
|
||||
Base.prepare(autoload_with=engine)
|
||||
session = Session(engine)
|
||||
|
||||
# define the classes
|
||||
Guild = Base.classes.Guilds
|
||||
CategoryGroup = Base.classes.CategoryGroups
|
||||
Category = Base.classes.Categories
|
||||
Score = Base.classes.Scores
|
||||
|
||||
submission_objects: SubmissionMap = SubmissionMap()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user