Skip to content

Commit

Permalink
release version 3.1.0 (#1254)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidism authored Sep 11, 2023
2 parents 9e19238 + 9a4d78f commit c8b77a8
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Version 3.1.0
-------------

Unreleased
Released 2023-09-10

- Drop support for Python 3.7. :pr:`1251`
- Add support for the SQLAlchemy 2.x API via ``model_class`` parameter. :issue:`1140`
Expand Down
2 changes: 1 addition & 1 deletion src/flask_sqlalchemy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from .extension import SQLAlchemy

__version__ = "3.1.0.dev"
__version__ = "3.1.0"

__all__ = [
"SQLAlchemy",
Expand Down
28 changes: 28 additions & 0 deletions src/flask_sqlalchemy/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,34 @@ def engine(self) -> sa.engine.Engine:
"""
return self.engines[None]

def get_engine(
self, bind_key: str | None = None, **kwargs: t.Any
) -> sa.engine.Engine:
"""Get the engine for the given bind key for the current application.
This requires that a Flask application context is active.
:param bind_key: The name of the engine.
.. deprecated:: 3.0
Will be removed in Flask-SQLAlchemy 3.2. Use ``engines[key]`` instead.
.. versionchanged:: 3.0
Renamed the ``bind`` parameter to ``bind_key``. Removed the ``app``
parameter.
"""
warnings.warn(
"'get_engine' is deprecated and will be removed in Flask-SQLAlchemy"
" 3.2. Use 'engine' or 'engines[key]' instead. If you're using"
" Flask-Migrate or Alembic, you'll need to update your 'env.py' file.",
DeprecationWarning,
stacklevel=2,
)

if "bind" in kwargs:
bind_key = kwargs.pop("bind")

return self.engines[bind_key]

def get_or_404(
self,
entity: type[_O],
Expand Down

0 comments on commit c8b77a8

Please sign in to comment.