Reputation: 2800
How does an SQLAlchemy transaction get deassociated from a connection? What should I do to prevent that?
Upvotes: 7
Views: 3432
Reputation: 55600
This warning is issued when SQLAlchemy tries to roll back a transaction, or a savepoint, which has already been rolled back. For example:
>>> import sqlalchemy as sa
>>> engine = sa.create_engine('sqlite:///', echo=True, future=True)
>>> with engine.connect() as conn:
... with conn.begin() as txn:
... txn.rollback()
... txn.rollback()
...
outputs
2021-06-12 15:13:13,669 INFO sqlalchemy.engine.Engine BEGIN (implicit)
2021-06-12 15:13:13,669 INFO sqlalchemy.engine.Engine ROLLBACK
<stdin>:4: SAWarning: transaction already deassociated from connection
You can see the two related unit tests here.
Upvotes: 10