diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2022-02-15 09:18:50 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2022-02-15 09:18:50 -0500 |
commit | 4db8f8ffbe7bf1e0c77c187159b0bb50f737e703 (patch) | |
tree | c69bcd88650f253468f3741582ee82bf767b4801 /docs | |
parent | d477aa6592bd9bafff99bdaf0e97f5befd790a14 (diff) | |
download | alembic-4db8f8ffbe7bf1e0c77c187159b0bb50f737e703.tar.gz |
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
Diffstat (limited to 'docs')
-rw-r--r-- | docs/build/cookbook.rst | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/docs/build/cookbook.rst b/docs/build/cookbook.rst index b5a4bb9..06a8075 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: |