I am following the factory design pattern. In the WSGI.py file, why does print(db) prints
<SQLAlchemy engine=None>
I have attached the app to db with db.init_app(app) command in MAIN.py file. Shouldn't the output be
<SQLAlchemy engine= "sqlite:///site.db">
My WSGI.py file
from main import create_app, db
app = create_app("sqlite:///site.db")
print(db)
if __name__ == "__main__" :
app.run(debug=True)
My MAIN.py file
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy()
def create_app(URI) :
app = Flask(__name__)
app.config["SQLALCHEMY_DATABASE_URI"] = URI
db.init_app(app)
return app