Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Merged
miss-islington merged 16 commits intopython:mainfromerlend-aasland:sqlite-ctx-mgr
Jun 19, 2022
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
16 commits
Select commitHold shift + click to select a range
672ce97
gh-61162: Clarify sqlite3 connection context manager docs
erlend-aaslandJun 16, 2022
61b31f9
Update Doc/library/sqlite3.rst
Jun 16, 2022
2434ba2
Address Adam's review: focus on the happy path
erlend-aaslandJun 16, 2022
71f2f45
Remove the now obsolete note
erlend-aaslandJun 16, 2022
76319b7
Clarify?
erlend-aaslandJun 16, 2022
20a100a
Update sqlite3.rst
Jun 16, 2022
28c435f
Add context manager anchor
Jun 16, 2022
6baac81
Use anchor in NEWS entry
Jun 16, 2022
8808fb9
Update Doc/library/sqlite3.rst
Jun 16, 2022
7237399
Add connection class link
Jun 16, 2022
6218dba
Make it more concise
Jun 16, 2022
32beb9f
Adjust wording and reflow for 79 chars
erlend-aaslandJun 17, 2022
a64fad4
Update Doc/library/sqlite3.rst
Jun 17, 2022
420c8ce
Object is singular
Jun 17, 2022
9fc3801
Reflow to 79 char limit
erlend-aaslandJun 17, 2022
b2ae22c
Finishing touch: Use neither...nor instead of does not...or
erlend-aaslandJun 19, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletionsDoc/library/sqlite3.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1431,13 +1431,27 @@ case-insensitively by name:
.. literalinclude:: ../includes/sqlite3/rowclass.py


.. _sqlite3-connection-context-manager:

Using the connection as a context manager
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Connection objects can be used as context managers
that automatically commit or rollback transactions. In the event of an
exception, the transaction is rolled back; otherwise, the transaction is
committed:
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.
If this commit fails,
or if the body of the ``with`` statement raises an uncaught exception,
the transaction is rolled back.

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

Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
Clarify :mod:`sqlite3` behavior when :ref:`sqlite3-connection-context-manager`.

[8]ページ先頭

©2009-2025 Movatter.jp