Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
gh-61162: Clarify sqlite3 connection context manager docs#93890
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
672ce9761b31f92434ba271f2f4576319b720a100a28c435f6baac818808fb972373996218dba32beb9fa64fad4420c8ce9fc3801b2ae22cFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1431,13 +1431,27 @@ case-insensitively by name: | ||
| .. literalinclude:: ../includes/sqlite3/rowclass.py | ||
| .. _sqlite3-connection-context-manager: | ||
| Using the connection as a context manager | ||
erlend-aasland marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
erlend-aasland marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| A :class:`Connection` object can be used as a context manager that | ||
| automatically commits or rolls back open transactions when leaving the body of | ||
| the context manager. | ||
| If the body of the :keyword:`with` statement finishes without exceptions, | ||
| the transaction is committed. | ||
erlend-aasland marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| If this commit fails, | ||
| or if the body of the ``with`` statement raises an uncaught exception, | ||
| the transaction is rolled back. | ||
erlend-aasland marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| If there is no open transaction upon leaving the body of the ``with`` statement, | ||
| the context manager is a no-op. | ||
| .. note:: | ||
| The context manager neither implicitly opens a new transaction | ||
| nor closes the connection. | ||
| .. literalinclude:: ../includes/sqlite3/ctx_manager.py | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Clarify :mod:`sqlite3` behavior when :ref:`sqlite3-connection-context-manager`. |