From: Mike Bayer Date: Tue, 15 Feb 2022 14:18:50 +0000 (-0500) Subject: repair sharing example X-Git-Tag: rel_1_7_7~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4db8f8ffbe7bf1e0c77c187159b0bb50f737e703;p=thirdparty%2Fsqlalchemy%2Falembic.git 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 --- 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: