summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Sewell <chrisj_sewell@hotmail.com>2021-09-11 08:12:10 +0200
committerGitHub <noreply@github.com>2021-09-11 08:12:10 +0200
commit1ccbc2145569b700e140f2fc27e22ef400682eb0 (patch)
tree5ea89189177b4b0edddded3a149182d3461b5d9a
parent3ac8dec3582a9a03212c99f56272d2ab842298fc (diff)
downloadalembic-1ccbc2145569b700e140f2fc27e22ef400682eb0.tar.gz
[DOCS]: Remove suggestion to use branched connections
Fixes #908
-rw-r--r--docs/build/cookbook.rst33
1 files changed, 12 insertions, 21 deletions
diff --git a/docs/build/cookbook.rst b/docs/build/cookbook.rst
index a3de0f8..6877580 100644
--- a/docs/build/cookbook.rst
+++ b/docs/build/cookbook.rst
@@ -233,30 +233,21 @@ Then in ``env.py``::
prefix='sqlalchemy.',
poolclass=pool.NullPool)
- # when connectable is already a Connection object, calling
- # connect() gives us a *branched connection*.
+ context.configure(
+ connection=connectable,
+ target_metadata=target_metadata
+ )
- with connectable.connect() as connection:
- context.configure(
- connection=connection,
- target_metadata=target_metadata
- )
+ with context.begin_transaction():
+ context.run_migrations()
- with context.begin_transaction():
- context.run_migrations()
+.. versionchanged:: 1.4
-.. topic:: Branched Connections
-
- Note that we are calling the ``connect()`` method, **even if we are
- using a** :class:`~sqlalchemy.engine.Connection` **object to start with**.
- The effect this has when calling :meth:`~sqlalchemy.engine.Connection.connect`
- is that SQLAlchemy passes us a **branch** of the original connection; it
- is in every way the same as the :class:`~sqlalchemy.engine.Connection`
- we started with, except it provides **nested scope**; the
- context we have here as well as the
- :meth:`~sqlalchemy.engine.Connection.close` method of this branched
- connection doesn't actually close the outer connection, which stays
- active for continued use.
+ Prior to this version, we used a "branched connection", by calling
+ :meth:`~sqlalchemy.engine.Connection.connect`.
+ This is now deprecated and unnecessary,
+ since we no longer have to guess if the given "connection"
+ is an ``Engine`` or ``Connection``, it is always a ``Connection``.
.. _replaceable_objects: