Skip to content

Commit c8b77a8

Browse files
authored
release version 3.1.0 (#1254)
2 parents 9e19238 + 9a4d78f commit c8b77a8

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

CHANGES.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Version 3.1.0
22
-------------
33

4-
Unreleased
4+
Released 2023-09-10
55

66
- Drop support for Python 3.7. :pr:`1251`
77
- Add support for the SQLAlchemy 2.x API via ``model_class`` parameter. :issue:`1140`

src/flask_sqlalchemy/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from .extension import SQLAlchemy
44

5-
__version__ = "3.1.0.dev"
5+
__version__ = "3.1.0"
66

77
__all__ = [
88
"SQLAlchemy",

src/flask_sqlalchemy/extension.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,34 @@ def engine(self) -> sa.engine.Engine:
708708
"""
709709
return self.engines[None]
710710

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+
711739
def get_or_404(
712740
self,
713741
entity: type[_O],

0 commit comments

Comments
 (0)