Feature or enhancement
Proposal:
SQLite 3.40.0 (November 2022) introduced a public recovery API for recovering data from corrupted databases: sqlite3_recover_init(), sqlite3_recover_step(), and sqlite3_recover_finish().
The sqlite3 standard library module already wraps somewhat comparable C APIs, like Connection.backup() wraps sqlite3_backup_* or Connection.blobopen() wraps sqlite3_blob_*, although maybe none of these are as involved as the recover extension.
Recovery currently requires users to shell out to the sqlite3 CLI binary, which is not always available. A GitHub serach for "subprocess.run" "sqlite3" ".recover" demonstrates that Python users often use subprocess to access this functionality, and often have dedicated exception handling for when sqlite3 binary is absent.
Potential API
This could be either a single recover() method, or three methods mirroring the C API. I am not opinionated, and frankly not knowledgeable enough on the topic to advocate for any particular API but for the sake of argument one could imagine mirroring the options of .recover CLI with:
Connection.recover(target, *, lost_and_found=None, ignore_freelist=False, no_rowids=False)
Maybe it could raise sqlite3.DatabaseError on unrecoverable failure.
Build / source availability
Since SQLite 3.41.0 includes sqlite3r.c Makefile target - an alternate amalgamation that bundles sqlite3recover.c and dbdata.c alongside the standard sqlite3.c.
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
Relevant SQLite versions:
- SQLite 3.29.0 (2019-10-04) added
.recover CLI option
- SQLite 3.40.0 (2022-11-16) added the recovery extension
- SQLite 3.41.0 (2023-02-21) added the
sqlite3r.c amalgamation that includes the recovery extension.
Previous discussions (outside of cpython, but still relevant IMO):
I would be interested in some kind of indication if this could potentially be accepted or if the slow adoption elsewhere and absence in the default amalgamation disqualify this extension as of 2026 (which of course can change later on).
Feature or enhancement
Proposal:
SQLite 3.40.0 (November 2022) introduced a public recovery API for recovering data from corrupted databases:
sqlite3_recover_init(),sqlite3_recover_step(), andsqlite3_recover_finish().The
sqlite3standard library module already wraps somewhat comparable C APIs, likeConnection.backup()wrapssqlite3_backup_*orConnection.blobopen()wrapssqlite3_blob_*, although maybe none of these are as involved as therecoverextension.Recovery currently requires users to shell out to the
sqlite3CLI binary, which is not always available. A GitHub serach for"subprocess.run" "sqlite3" ".recover"demonstrates that Python users often use subprocess to access this functionality, and often have dedicated exception handling for whensqlite3binary is absent.Potential API
This could be either a single
recover()method, or three methods mirroring the C API. I am not opinionated, and frankly not knowledgeable enough on the topic to advocate for any particular API but for the sake of argument one could imagine mirroring the options of.recoverCLI with:Maybe it could raise
sqlite3.DatabaseErroron unrecoverable failure.Build / source availability
Since SQLite 3.41.0 includes
sqlite3r.cMakefile target - an alternate amalgamation that bundlessqlite3recover.canddbdata.calongside the standardsqlite3.c.Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
Relevant SQLite versions:
.recoverCLI optionsqlite3r.camalgamation that includes the recovery extension.Previous discussions (outside of cpython, but still relevant IMO):
.recoverCLIrusqlite) explored it back in May 2023 but seemingly did not know about the newsqlite3r.camalgamation Add Recovery Extension Support rusqlite/rusqlite#1333I would be interested in some kind of indication if this could potentially be accepted or if the slow adoption elsewhere and absence in the default amalgamation disqualify this extension as of 2026 (which of course can change later on).