Visitar URL original
gh-69093: Add context manager support to sqlite3.Blob by erlend-aasland · Pull Request #91562 · python/cpython · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
Try to consolidate examples and reword docs
  • Loading branch information
Erlend E. Aasland
Erlend E. Aasland committed Apr 15, 2022
commit ca093f3aae984581edc1fe1c68879f658dc1d039
3 changes: 3 additions & 0 deletions Doc/includes/sqlite3/blob.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@
blob.seek(0)
print(blob.read()) # will print b"HelloWorld"
blob.close()

with con.blobopen("test", "blob_col", 1) as blob:
blob.write(b"UpdateBlob")
12 changes: 0 additions & 12 deletions Doc/includes/sqlite3/blob_with.py

This file was deleted.

7 changes: 3 additions & 4 deletions Doc/library/sqlite3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1115,6 +1115,9 @@ Blob Objects
data in an SQLite :abbr:`BLOB (Binary Large OBject)`. Call ``len(blob)`` to
get the size (number of bytes) of the blob.

Use the :class:`Blob` as a :term:`context manager` to ensure that the blob
handle is closed after use.

.. method:: close()

Close the blob.
Expand Down Expand Up @@ -1153,10 +1156,6 @@ Blob Objects

.. literalinclude:: ../includes/sqlite3/blob.py

A :class:`Blob` can also be used as a :term:`context manager`:

.. literalinclude:: ../includes/sqlite3/blob_with.py


.. _sqlite3-types:

Expand Down