Fixed database connection issue

This commit is contained in:
Vivek Santayana 2022-06-11 15:16:35 +01:00
parent eac9ee7ab1
commit 625ef8883b
11 changed files with 19 additions and 15 deletions

View File

@ -1,4 +1,8 @@
from .modules import bootstrap, csrf, db, login_manager, mail from .modules.bootstrap import bootstrap
from .modules.csrf import csrf
from .modules.db import db
from .modules.login_manager import login_manager
from .modules.mail import mail
from .config import DevelopmentConfig as Config from .config import DevelopmentConfig as Config
from flask import Flask from flask import Flask

View File

@ -5,12 +5,12 @@ from pathlib import Path
class Config(object): class Config(object):
APP_HOST = '0.0.0.0' APP_HOST = '0.0.0.0'
DATA_FILE_DIRECTORY = os.getenv('DATA_FILE_DIRECTORY') DATA = os.getenv('DATA')
DEBUG = False DEBUG = False
TESTING = False TESTING = False
SECRET_KEY = os.getenv('SECRET_KEY') SECRET_KEY = os.getenv('SECRET_KEY')
SESSION_COOKIE_SECURE = True SESSION_COOKIE_SECURE = True
SQLALCHEMY_DATABASE_URI = f'sqlite:///{Path(DATA_FILE_DIRECTORY)}/database.db' SQLALCHEMY_DATABASE_URI = f'sqlite:///{Path(DATA)}/database.db'
SQLALCHEMY_TRACK_MODIFICATIONS = False SQLALCHEMY_TRACK_MODIFICATIONS = False
MAIL_SERVER = os.getenv('MAIL_SERVER') MAIL_SERVER = os.getenv('MAIL_SERVER')

View File

@ -2,4 +2,4 @@ from . import Config
from os import path from os import path
from pathlib import Path from pathlib import Path
data = Path(Config.DATA_FILE_DIRECTORY) data = Path(Config.DATA)

View File

@ -1,7 +1,7 @@
from main import app from main import app
from . import Config from . import Config
from .data import data from .data import data
from .modules import db from .modules.db import db
from .tools.data import save from .tools.data import save
from .tools.logs import write from .tools.logs import write

View File

@ -1,10 +0,0 @@
from flask_bootstrap import Bootstrap
bootstrap = Bootstrap()
from flask_wtf.csrf import CSRFProtect
csrf = CSRFProtect()
from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy()
from flask_login import LoginManager
login_manager = LoginManager()
from flask_mail import Mail
mail = Mail()

View File

View File

@ -0,0 +1,2 @@
from flask_bootstrap import Bootstrap
bootstrap = Bootstrap()

View File

@ -0,0 +1,2 @@
from flask_wtf.csrf import CSRFProtect
csrf = CSRFProtect()

View File

@ -0,0 +1,2 @@
from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy()

View File

@ -0,0 +1,2 @@
from flask_login import LoginManager
login_manager = LoginManager()

View File

@ -0,0 +1,2 @@
from flask_mail import Mail
mail = Mail()