On Fri, Mar 5, 2021, at 11:00 AM, Jonathan Brandmeyer wrote:
>
>
> On Fri, Mar 5, 2021 at 8:29 AM Mike Bayer <[email protected]> wrote:
>> __
>> Can I ask what documentation led you to believe that engine.connect() was
>> somehow being removed ?
>
> The guidance at [1] makes it clear that the connection is available as a
> transaction context manager. However, the guidance at [2] suggests that the
> preferred method is to use the engine.
>
> [1]:
> https://docs.sqlalchemy.org/en/14/changelog/migration_20.html#migration-core-connection-transaction
> [2]:
> https://docs.sqlalchemy.org/en/14/changelog/migration_20.html#many-choices-becomes-one-choice
OK, so the term "one choice" is clarified at the end, that there are "one and a
half" choices - that is, there are still two syntaxes that are appropriate, but
the "one choice" refers to the fact that you are always using an explicit
Connection:
# one choice!
with engine.begin() as conn:
result = conn.execute(stmt)
# OK one and a half choices (the commit() is 1.4 / 2.0 using future engine):
with engine.connect() as conn:
result = conn.execute(stmt)
conn.commit()
you're using the second pattern. "with conn.begin()" is also still valid
though is not strictly necessary in 2.0.
I will modify the verbiage now.
> Thanks,
> --
> Jonathan Brandmeyer
>
> --
> SQLAlchemy -
> The Python SQL Toolkit and Object Relational Mapper
>
> http://www.sqlalchemy.org/
>
> To post example code, please provide an MCVE: Minimal, Complete, and
> Verifiable Example. See http://stackoverflow.com/help/mcve for a full
> description.
> ---
> You received this message because you are subscribed to the Google Groups
> "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sqlalchemy/CA%2BXzfkpqV2PDBm9EQYBZT6jiO_ZKHR1uKn%2BwB90t2D23An10ug%40mail.gmail.com
>
> <https://groups.google.com/d/msgid/sqlalchemy/CA%2BXzfkpqV2PDBm9EQYBZT6jiO_ZKHR1uKn%2BwB90t2D23An10ug%40mail.gmail.com?utm_medium=email&utm_source=footer>.
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
http://www.sqlalchemy.org/
To post example code, please provide an MCVE: Minimal, Complete, and Verifiable
Example. See http://stackoverflow.com/help/mcve for a full description.
---
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/sqlalchemy/775f0f55-1700-4eb9-968e-6f8a2cf7beaa%40www.fastmail.com.