diff --git a/backend/app/core.py b/backend/app/core.py index a36f4b8..3215e9f 100644 --- a/backend/app/core.py +++ b/backend/app/core.py @@ -5,6 +5,7 @@ from app.config import Config from flask import Flask, session from flask_restful import Api from flask_sqlalchemy import SQLAlchemy +from sqlalchemy import MetaData from sqlalchemy import create_engine from sqlalchemy.ext.automap import automap_base @@ -26,6 +27,7 @@ db = SQLAlchemy(app) Base = automap_base() engine = create_engine(app.config["SQLALCHEMY_DATABASE_URI"]) Base.prepare(engine, reflect=True) +meta = MetaData(engine, True) # RestFul Flask api = Api(app) diff --git a/backend/app/model.py b/backend/app/model.py index 9fc2663..a6468ea 100644 --- a/backend/app/model.py +++ b/backend/app/model.py @@ -1,9 +1,10 @@ -from app.core import Base +from app.core import meta +from sqlalchemy import Table -USER = Base.classes.user -SETTINGS = Base.classes.settings -HASHTABLE = Base.classes.hashtable -GROUP = Base.classes.group -GROUP_CONTENT = Base.classes.group_content -PERIOD = Base.classes.period -LIVRET = Base.classes.livret +USER = Table('USER', meta, autoload=False) +SETTINGS = Table('SETTINGS', meta, autoload=False) +HASHTABLE = Table('HASHTABLE', meta, autoload=False) +GROUP = Table('GROUP', meta, autoload=False) +TUTORSHIP = Table('TUTORSHIP', meta, autoload=False) +PERIOD = Table('PERIOD', meta, autoload=False) +LIVRET = Table('LIVRET', meta, autoload=False) diff --git a/backend/manage.py b/backend/manage.py index 93493c3..7142293 100644 --- a/backend/manage.py +++ b/backend/manage.py @@ -4,11 +4,10 @@ import os import unittest import warnings +from app.config import Config from flask_script import Manager, Command from flask_script import prompt_bool -from app.config import Config - warnings.simplefilter('ignore') parser = argparse.ArgumentParser() @@ -25,6 +24,7 @@ else: Config.configure_app(config="prod") core = importlib.import_module("app.core") +model = importlib.import_module("backend.app.model") manager = Manager(core.app) manager.add_option("-d", "--debug", @@ -59,7 +59,12 @@ class CheckDB(Command): def run(self): print("List of parsed tables:") - print(core.db.metadata.tables.keys()) + print(core.meta.tables.keys()) + query = model.SETTINGS.select() + result = query.execute() + print("\nSETTINGS content :") + for res in result: + print(res.key + " = " + res.value) manager.add_command('checkdb', CheckDB())