File tree Expand file tree Collapse file tree 3 files changed +30
-2
lines changed Expand file tree Collapse file tree 3 files changed +30
-2
lines changed Original file line number Diff line number Diff line change 1
1
Version 3.1.0
2
2
-------------
3
3
4
- Unreleased
4
+ Released 2023-09-10
5
5
6
6
- Drop support for Python 3.7. :pr: `1251 `
7
7
- Add support for the SQLAlchemy 2.x API via ``model_class `` parameter. :issue: `1140 `
Original file line number Diff line number Diff line change 2
2
3
3
from .extension import SQLAlchemy
4
4
5
- __version__ = "3.1.0.dev "
5
+ __version__ = "3.1.0"
6
6
7
7
__all__ = [
8
8
"SQLAlchemy" ,
Original file line number Diff line number Diff line change @@ -708,6 +708,34 @@ def engine(self) -> sa.engine.Engine:
708
708
"""
709
709
return self .engines [None ]
710
710
711
+ def get_engine (
712
+ self , bind_key : str | None = None , ** kwargs : t .Any
713
+ ) -> sa .engine .Engine :
714
+ """Get the engine for the given bind key for the current application.
715
+ This requires that a Flask application context is active.
716
+
717
+ :param bind_key: The name of the engine.
718
+
719
+ .. deprecated:: 3.0
720
+ Will be removed in Flask-SQLAlchemy 3.2. Use ``engines[key]`` instead.
721
+
722
+ .. versionchanged:: 3.0
723
+ Renamed the ``bind`` parameter to ``bind_key``. Removed the ``app``
724
+ parameter.
725
+ """
726
+ warnings .warn (
727
+ "'get_engine' is deprecated and will be removed in Flask-SQLAlchemy"
728
+ " 3.2. Use 'engine' or 'engines[key]' instead. If you're using"
729
+ " Flask-Migrate or Alembic, you'll need to update your 'env.py' file." ,
730
+ DeprecationWarning ,
731
+ stacklevel = 2 ,
732
+ )
733
+
734
+ if "bind" in kwargs :
735
+ bind_key = kwargs .pop ("bind" )
736
+
737
+ return self .engines [bind_key ]
738
+
711
739
def get_or_404 (
712
740
self ,
713
741
entity : type [_O ],
You can’t perform that action at this time.
0 commit comments