From dd8685b1039a6bdcbe1df0b07c2ef5d72399c876 Mon Sep 17 00:00:00 2001 From: viveksantayana Date: Sat, 11 Jun 2022 15:16:35 +0100 Subject: [PATCH] Fixed database connection issue --- ref-test/app/__init__.py | 6 +++++- ref-test/app/config.py | 4 ++-- ref-test/app/data.py | 2 +- ref-test/app/install.py | 2 +- ref-test/app/modules.py | 10 ---------- ref-test/app/modules/__init__.py | 0 ref-test/app/modules/bootstrap.py | 2 ++ ref-test/app/modules/csrf.py | 2 ++ ref-test/app/modules/db.py | 2 ++ ref-test/app/modules/login_manager.py | 2 ++ ref-test/app/modules/mail.py | 2 ++ 11 files changed, 19 insertions(+), 15 deletions(-) delete mode 100644 ref-test/app/modules.py create mode 100644 ref-test/app/modules/__init__.py create mode 100644 ref-test/app/modules/bootstrap.py create mode 100644 ref-test/app/modules/csrf.py create mode 100644 ref-test/app/modules/db.py create mode 100644 ref-test/app/modules/login_manager.py create mode 100644 ref-test/app/modules/mail.py diff --git a/ref-test/app/__init__.py b/ref-test/app/__init__.py index 629d0da..a8ae420 100644 --- a/ref-test/app/__init__.py +++ b/ref-test/app/__init__.py @@ -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 flask import Flask diff --git a/ref-test/app/config.py b/ref-test/app/config.py index 1218069..cd987bd 100644 --- a/ref-test/app/config.py +++ b/ref-test/app/config.py @@ -5,12 +5,12 @@ from pathlib import Path class Config(object): APP_HOST = '0.0.0.0' - DATA_FILE_DIRECTORY = os.getenv('DATA_FILE_DIRECTORY') + DATA = os.getenv('DATA') DEBUG = False TESTING = False SECRET_KEY = os.getenv('SECRET_KEY') 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 MAIL_SERVER = os.getenv('MAIL_SERVER') diff --git a/ref-test/app/data.py b/ref-test/app/data.py index 16b25a7..b6b4ce1 100644 --- a/ref-test/app/data.py +++ b/ref-test/app/data.py @@ -2,4 +2,4 @@ from . import Config from os import path from pathlib import Path -data = Path(Config.DATA_FILE_DIRECTORY) +data = Path(Config.DATA) diff --git a/ref-test/app/install.py b/ref-test/app/install.py index 177d70a..2157b83 100644 --- a/ref-test/app/install.py +++ b/ref-test/app/install.py @@ -1,7 +1,7 @@ from main import app from . import Config from .data import data -from .modules import db +from .modules.db import db from .tools.data import save from .tools.logs import write diff --git a/ref-test/app/modules.py b/ref-test/app/modules.py deleted file mode 100644 index 873c3d1..0000000 --- a/ref-test/app/modules.py +++ /dev/null @@ -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() \ No newline at end of file diff --git a/ref-test/app/modules/__init__.py b/ref-test/app/modules/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/ref-test/app/modules/bootstrap.py b/ref-test/app/modules/bootstrap.py new file mode 100644 index 0000000..32a6a6a --- /dev/null +++ b/ref-test/app/modules/bootstrap.py @@ -0,0 +1,2 @@ +from flask_bootstrap import Bootstrap +bootstrap = Bootstrap() \ No newline at end of file diff --git a/ref-test/app/modules/csrf.py b/ref-test/app/modules/csrf.py new file mode 100644 index 0000000..edda995 --- /dev/null +++ b/ref-test/app/modules/csrf.py @@ -0,0 +1,2 @@ +from flask_wtf.csrf import CSRFProtect +csrf = CSRFProtect() \ No newline at end of file diff --git a/ref-test/app/modules/db.py b/ref-test/app/modules/db.py new file mode 100644 index 0000000..589c64f --- /dev/null +++ b/ref-test/app/modules/db.py @@ -0,0 +1,2 @@ +from flask_sqlalchemy import SQLAlchemy +db = SQLAlchemy() \ No newline at end of file diff --git a/ref-test/app/modules/login_manager.py b/ref-test/app/modules/login_manager.py new file mode 100644 index 0000000..4a9813d --- /dev/null +++ b/ref-test/app/modules/login_manager.py @@ -0,0 +1,2 @@ +from flask_login import LoginManager +login_manager = LoginManager() \ No newline at end of file diff --git a/ref-test/app/modules/mail.py b/ref-test/app/modules/mail.py new file mode 100644 index 0000000..6636ec6 --- /dev/null +++ b/ref-test/app/modules/mail.py @@ -0,0 +1,2 @@ +from flask_mail import Mail +mail = Mail() \ No newline at end of file