chore: support sqlalchemy 2.x and flask-sqlalchemy 3 (breaking) - #2241
Conversation
|
Related: #2240 |
This reverts commit 9b19585.
|
Also another question.. Have you thought about bumping flask to allow 3 as well? We have connexion, finally updating their old 2.* release to allow us to finally bump Werkzeug spec-first/connexion#1992 (comment) -> but it is flask 3+ only, so we cannot really do it before FAB can support Flask 3+. |
|
Nice. I guess we should be able to revert some of our workarounds with @vincbeck :D |
…my-2 # Conflicts: # flask_appbuilder/__init__.py # flask_appbuilder/api/__init__.py # flask_appbuilder/exceptions.py
Sorry, for the delay here. But I've release 5.0.0a9 for early testing.
|
Fantastic. @vincbeck - seems that another round of testing for us ;) Thanks @dpgaspar for the information |
|
Thanks @dpgaspar! Yep we go back to our PR and remove some (dirty) workarounds :) |
Great! I'll be reviving Superset's integration/PR. Tell me how the Airflow part went |
This is great! Thanks @dpgaspar, I could successfully use the official |
Flask-AppBuilder 5.0.0 - Breaking Changes Release
This major release introduces SQLAlchemy 2.x support alongside 1.4.x compatibility and includes several breaking changes to improve the framework's architecture and compatibility with the modern Flask ecosystem.
Breaking Changes
1. Session Access Changes
Breaking: Session access method has been renamed.
Before:
After:
2. Application Context Requirements
Breaking: Database queries now require application context (consistent with Flask-SQLAlchemy behavior).
3. SQLAInterface Exception Handling
Breaking: SQLAInterface no longer swallows exceptions and accepts an optional commit parameter.
Before:
After:
4. Application Reference Changes
Breaking:
appbuilder.get_appmethod has been removed.Before:
After:
5. Model Table Names
Breaking: All user models now require explicit
__tablename__attributes for SQLAlchemy 2.x compatibility.Before:
After:
6. New Configuration Options
New:
FAB_CREATE_DBconfiguration option to control automatic table creation.Migration Guide
Step 1: Add Table Names to Models
Ensure all your models have the
__tablename__SQLAlchemy attribute defined.Step 2: Update Session Access
Replace all instances of
appbuilder.sm.get_sessionwithappbuilder.sm.session.Step 3: Add Application Context
Ensure all database queries are wrapped in application context when needed.
Step 4: Update Application References
Replace
appbuilder.get_appcalls withcurrent_appimports.Step 5: Review Exception Handling
Update any code that relied on SQLAInterface swallowing exceptions.
Compatibility
Utility Functions
The
flask_appbuilder.utils.legacy.get_sqla_class()function helps maintain compatibility between SQLAlchemy versions and provides a smooth migration path.ADDITIONAL INFORMATION
This is a BREAKING CHANGE release - please review the migration guide carefully before upgrading.