From 4db8f8ffbe7bf1e0c77c187159b0bb50f737e703 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Tue, 15 Feb 2022 09:18:50 -0500 Subject: [PATCH] repair sharing example the note re: "we dont have to guess" is wrong. engine_from_config() returns an engine. It seems like this example was edited a few times and was not completely checked (it was me, for sure). for now just use two separate blocks to eliminate any problems Change-Id: Ib44671526d0f570ed88dd3b1c77d078c1afbf3eb --- docs/build/cookbook.rst | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/docs/build/cookbook.rst b/docs/build/cookbook.rst index b5a4bb94..06a80751 100644 --- a/docs/build/cookbook.rst +++ b/docs/build/cookbook.rst @@ -233,21 +233,22 @@ Then in ``env.py``:: prefix='sqlalchemy.', poolclass=pool.NullPool) - 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() + else: + context.configure( + connection=connectable, + target_metadata=target_metadata + ) -.. versionchanged:: 1.4 + with context.begin_transaction(): + context.run_migrations() - 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: -- 2.47.2