I'm having trouble getting my app to start when using a create_app() function. I'm new to building apps to this way and from all of my research it seems that my approach is different because I'm using my own database wrapper and not SQLAlchemy—which makes it easy because db.init_app(app) can be used.
My question is: I can't seem to access my database connection in /models/user.py... how do I fix this so I can use the db connection in that file?
This is my folder structure for the app, followed by those files listed:
/api
/common
database.py
/models
user.py
/resources
user.py
app.py
run.py
Here are my files
#
# File: run.py
#
from api.app import create_app
app = create_app(debug=True)
app.run(
host=app.config['APP_HOST'],
port=app.config['APP_PORT'],
debug=app.config['APP_DEBUG_FLASK'],
ssl_context=app.config['APP_SSL_CONTEXT']
)
#
# File: app.py
#
from logging.config import dictConfig
from flask import Flask
from flask_restful import Api
from api.config import LocalConfig, LiveConfig
from api.extensions import bcrypt, cors, jwt
from api.resources.user import *
from api.common.database import Database