python 3.x – SQLALCHEMY_DATABASE_URI not set
python 3.x – SQLALCHEMY_DATABASE_URI not set
You probably need to put this line app.config[SQLALCHEMY_DATABASE_URI] = mysql...
before the SQLAlchemy(app)
instanciation.
Another option is to create SQLAlchemy()
without parametters, to configure URI, and finally to tell SQLAlchemy
to link with your app via sqldb.init_app(app)
Note that it is what youve done in your create_app
function, but you never use it ?
Like the answer above, if you use it this way, change
sqldb = SQLAlchemy(app)
to
sqldb = SQLAlchemy()
python 3.x – SQLALCHEMY_DATABASE_URI not set
I got the same error, and it was gone after setting the FLASK_APP environment variable :
export FLASK_APP=run.py
Start the application :
flask run --host=0.0.0.0 --port=5000