diff --git a/src/flask_migrate/templates/aioflask-multidb/env.py b/src/flask_migrate/templates/aioflask-multidb/env.py index fa6fd3a..c3af269 100644 --- a/src/flask_migrate/templates/aioflask-multidb/env.py +++ b/src/flask_migrate/templates/aioflask-multidb/env.py @@ -21,10 +21,10 @@ def get_engine(bind_key=None): try: - # this works with Flask-SQLAlchemy<3 and Alchemical + # this works with Flask-SQLAlchemy<3.1 and Alchemical return current_app.extensions['migrate'].db.get_engine(bind=bind_key) - except TypeError: - # this works with Flask-SQLAlchemy>=3 + except AttributeError: + # this works with Flask-SQLAlchemy>=3.1 return current_app.extensions['migrate'].db.engines.get(bind_key) diff --git a/src/flask_migrate/templates/aioflask/env.py b/src/flask_migrate/templates/aioflask/env.py index ecbd77f..20daee2 100644 --- a/src/flask_migrate/templates/aioflask/env.py +++ b/src/flask_migrate/templates/aioflask/env.py @@ -18,10 +18,10 @@ def get_engine(): try: - # this works with Flask-SQLAlchemy<3 and Alchemical + # this works with Flask-SQLAlchemy<3.1 and Alchemical return current_app.extensions['migrate'].db.get_engine() - except TypeError: - # this works with Flask-SQLAlchemy>=3 + except AttributeError: + # this works with Flask-SQLAlchemy>=3.1 return current_app.extensions['migrate'].db.engine diff --git a/src/flask_migrate/templates/flask-multidb/env.py b/src/flask_migrate/templates/flask-multidb/env.py index ed6966f..00ac0da 100644 --- a/src/flask_migrate/templates/flask-multidb/env.py +++ b/src/flask_migrate/templates/flask-multidb/env.py @@ -20,10 +20,10 @@ def get_engine(bind_key=None): try: - # this works with Flask-SQLAlchemy<3 and Alchemical + # this works with Flask-SQLAlchemy<3.1 and Alchemical return current_app.extensions['migrate'].db.get_engine(bind=bind_key) - except TypeError: - # this works with Flask-SQLAlchemy>=3 + except AttributeError: + # this works with Flask-SQLAlchemy>=3.1 return current_app.extensions['migrate'].db.engines.get(bind_key) diff --git a/src/flask_migrate/templates/flask/env.py b/src/flask_migrate/templates/flask/env.py index f497a74..cf65158 100644 --- a/src/flask_migrate/templates/flask/env.py +++ b/src/flask_migrate/templates/flask/env.py @@ -17,10 +17,10 @@ def get_engine(): try: - # this works with Flask-SQLAlchemy<3 and Alchemical + # this works with Flask-SQLAlchemy<3.1 and Alchemical return current_app.extensions['migrate'].db.get_engine() - except TypeError: - # this works with Flask-SQLAlchemy>=3 + except AttributeError: + # this works with Flask-SQLAlchemy>=3.1 return current_app.extensions['migrate'].db.engine