File tree Expand file tree Collapse file tree 1 file changed +17
-4
lines changed Expand file tree Collapse file tree 1 file changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -1553,14 +1553,27 @@ case-insensitively by name:
15531553
15541554.. literalinclude :: ../includes/sqlite3/rowclass.py
15551555
1556+ .. _sqlite3-connection-context-manager :
15561557
15571558Using the connection as a context manager
15581559^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
15591560
1560- Connection objects can be used as context managers
1561- that automatically commit or rollback transactions. In the event of an
1562- exception, the transaction is rolled back; otherwise, the transaction is
1563- committed:
1561+ A :class: `Connection ` object can be used as a context manager that
1562+ automatically commits or rolls back open transactions when leaving the body of the
1563+ context manager.
1564+ If the body of the :keyword: `with ` statement finishes without exceptions,
1565+ the transaction is committed.
1566+ If this commit fails,
1567+ or if the body of the ``with `` statement raises an uncaught exception,
1568+ the transaction is rolled back.
1569+
1570+ If there is no open transaction upon leaving the body of the ``with `` statement,
1571+ the context manager is a no-op.
1572+
1573+ .. note ::
1574+
1575+ The context manager does not implicitly open a new transaction
1576+ or close the connection.
15641577
15651578.. literalinclude :: ../includes/sqlite3/ctx_manager.py
15661579
You can’t perform that action at this time.
0 commit comments