diff options
author | Erlend Egeberg Aasland <erlend.aasland@innova.no> | 2022-04-05 14:15:25 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-05 14:15:25 (GMT) |
commit | a7551247e7cb7010fb4735281f1afa4abeb8a9cc (patch) | |
tree | 299c8b5dc3965692a2be95bc657c6d5f81ded105 /Doc | |
parent | aa0f056a00c4bcaef83d729e042359ddae903382 (diff) | |
download | cpython-a7551247e7cb7010fb4735281f1afa4abeb8a9cc.zip cpython-a7551247e7cb7010fb4735281f1afa4abeb8a9cc.tar.gz cpython-a7551247e7cb7010fb4735281f1afa4abeb8a9cc.tar.bz2 |
bpo-41930: Add support for SQLite serialise/deserialise API (GH-26728)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/sqlite3.rst | 38 | ||||
-rw-r--r-- | Doc/whatsnew/3.11.rst | 5 |
2 files changed, 43 insertions, 0 deletions
diff --git a/Doc/library/sqlite3.rst b/Doc/library/sqlite3.rst index e70d038..852b684 100644 --- a/Doc/library/sqlite3.rst +++ b/Doc/library/sqlite3.rst @@ -748,6 +748,44 @@ Connection Objects .. versionadded:: 3.11 + .. method:: serialize(*, name="main") + + This method serializes a database into a :class:`bytes` object. For an + ordinary on-disk database file, the serialization is just a copy of the + disk file. For an in-memory database or a "temp" database, the + serialization is the same sequence of bytes which would be written to + disk if that database were backed up to disk. + + *name* is the database to be serialized, and defaults to the main + database. + + .. note:: + + This method is only available if the underlying SQLite library has the + serialize API. + + .. versionadded:: 3.11 + + + .. method:: deserialize(data, /, *, name="main") + + This method causes the database connection to disconnect from database + *name*, and reopen *name* as an in-memory database based on the + serialization contained in *data*. Deserialization will raise + :exc:`OperationalError` if the database connection is currently involved + in a read transaction or a backup operation. :exc:`DataError` will be + raised if ``len(data)`` is larger than ``2**63 - 1``, and + :exc:`DatabaseError` will be raised if *data* does not contain a valid + SQLite database. + + .. note:: + + This method is only available if the underlying SQLite library has the + deserialize API. + + .. versionadded:: 3.11 + + .. _sqlite3-cursor-objects: Cursor Objects diff --git a/Doc/whatsnew/3.11.rst b/Doc/whatsnew/3.11.rst index d0c10a9..c312645 100644 --- a/Doc/whatsnew/3.11.rst +++ b/Doc/whatsnew/3.11.rst @@ -366,6 +366,11 @@ sqlite3 Instead we leave it to the SQLite library to handle these cases. (Contributed by Erlend E. Aasland in :issue:`44092`.) +* Add :meth:`~sqlite3.Connection.serialize` and + :meth:`~sqlite3.Connection.deserialize` to :class:`sqlite3.Connection` for + serializing and deserializing databases. + (Contributed by Erlend E. Aasland in :issue:`41930`.) + sys --- |