TG-35 : Test de la connexion à la BDD

This commit is contained in:
Clément ARNAUDEAU
2017-01-20 14:07:59 +01:00
parent c8d8d2f47e
commit bd9110b0fb
5 changed files with 34 additions and 11 deletions

View File

@ -22,6 +22,7 @@ class Prod(Config):
class Debug(Config):
DEBUG = True
SESSION_COOKIE_SECURE = False
SQLALCHEMY_DATABASE_URI = 'mysql://ola:ola@localhost/OLA'
class Test(Config):

View File

@ -1,10 +1,11 @@
import importlib
from datetime import timedelta
from flask import Flask, session
from flask_restful import Api
from flask_sqlalchemy import SQLAlchemy
import importlib
from sqlalchemy import create_engine
from sqlalchemy.ext.automap import automap_base
def configure_app(config="prod"):
@ -32,6 +33,9 @@ configure_app()
# SQLAlchemy
db = SQLAlchemy(app)
Base = automap_base()
engine = create_engine(app.config["SQLALCHEMY_DATABASE_URI"])
Base.prepare(engine, reflect=True)
# RestFul Flask
api = Api(app)

9
backend/app/model.py Normal file
View File

@ -0,0 +1,9 @@
from backend.app.core import Base
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