Error in Tutorial 2
I am getting this error in tutorial 2 and I am unable to create the database to store the user sign-up info
from flask_sqlalchemy import SQLAlchemy from .extension import SQLAlchemy from .model import _QueryProperty class DefaultMeta(BindMetaMixin, NameMetaMixin, sa.orm.DeclarativeMeta): AttributeError: module 'sqlalchemy.orm' has no attribute 'DeclarativeMeta'
Flask-SQLAlchemy 3 no longer accepts an app argument to methods like create_all. Instead, it always requires an active Flask application context. There is no need for the create_database function. So instead write this in the create app function
with app.app_context(): db.create_all()
i hope this solves your problem
I had a similar error giving me sqlite3.OperationalError: no such table: user. This fix worked though. Thanks @prranavv!