A SQLite file can miss committed records when its WAL is left behind
You copy a SQLite database file, open the copy successfully and find no rows in a table. That can be an accurate description of the copy while being an inaccurate description of the database you meant to preserve.
In write-ahead logging, or WAL mode, committed changes can still reside in the companion -wal file. Before reporting that a record was absent, establish whether your acquisition captured the database’s logical state or only its main file.

Committed does not mean copied into the main file
SQLite’s WAL documentation describes commits being appended to the log and checkpoints transferring changes into the main database. It treats the WAL as part of the persistent database state. Separating the files can lose committed transactions or produce corruption.
This is different from recovering a deleted record. The record in the exercise below is committed and visible to a normal query; the deliberately incomplete copy simply omits the place where that change is currently stored. The -shm companion serves shared-memory coordination and indexing functions; do not treat either suffix as permission to discard received files.
One row, three views
This synthetic local exercise creates a new temporary database. It never opens an existing research database, browser history or application file. The main-file copy is intentionally incomplete, made while our single writer is idle. It is a demonstration of the mistake, not a recipe for copying an active database.
from pathlib import Path
import shutil
import sqlite3
import tempfile
# A new synthetic database, never an existing evidence file.
folder = Path(tempfile.mkdtemp(prefix="osintjet-wal-demo-"))
source = folder / "demo.db"
db = sqlite3.connect(source, isolation_level=None)
assert db.execute("PRAGMA journal_mode=WAL").fetchone()[0] == "wal"
db.execute("PRAGMA wal_autocheckpoint=0")
db.execute("CREATE TABLE notes (label TEXT)")
db.execute("PRAGMA wal_checkpoint(TRUNCATE)")
db.execute("INSERT INTO notes VALUES ('fictional observation')")
print("logical:", db.execute("SELECT count(*) FROM notes").fetchone()[0])
# Deliberately incomplete copy; the single writer is idle here.
copy_path = folder / "main-only.db"
shutil.copyfile(source, copy_path)
copied = sqlite3.connect(copy_path)
print("main only:", copied.execute("SELECT count(*) FROM notes").fetchone()[0])
copied.close()
snapshot = sqlite3.connect(folder / "logical-backup.db")
db.backup(snapshot)
print("backup:", snapshot.execute("SELECT count(*) FROM notes").fetchone()[0])
snapshot.close()
db.close()
print("exercise files:", folder)
The setup first checkpoints the empty table. It then commits one fictional observation while automatic checkpointing is disabled for this exercise connection. Keeping the connection open preserves the comparison point. A local run using Python 3.12.10 and SQLite 3.49.1 produced:
| View examined | Rows | What the result describes |
|---|---|---|
| Query through the source connection | 1 | The committed logical table |
| Copy of the main file alone | 0 | The earlier checkpointed table |
| SQLite backup output | 1 | The logical snapshot produced by the backup operation |
Opening the incomplete copy without an error did not establish completeness. Conversely, the zero does not prove that someone deleted the observation. The acquisition method accounts for the difference in this controlled example.
Choose what you are preserving
For an authorized working database where the goal is a consistent, queryable snapshot, SQLite provides its online backup mechanism; Python exposes it through Connection.backup. Record that a logical backup was made, its completion time and the software versions. Do not describe that output as an untouched copy of every original physical artifact.
Preserving the received physical evidence is a different task. Retain the original package and its companion files before opening a working copy. Record the acquisition process, filenames, sizes and hashes. Do not delete a WAL or force a checkpoint on original evidence merely to make the folder look simpler: that can change the state you wanted to document.
Nor does copying the main file and then the WAL from a changing source guarantee a coherent pair. They may be captured at different stages. Use an appropriate consistent acquisition method for that source, and document its limits. The quiet, single-writer teaching setup above deliberately removes that concurrency problem; it does not solve it for a real application.
A missing sidecar is a question, not a verdict
A cleanly closed database may no longer need a WAL, so the absence of a -wal file alone does not establish a faulty capture. Ask how the package was produced: a documented application export, a completed logical backup, or a filesystem copy taken during use? Keep “unknown acquisition method” distinct from “known incomplete acquisition.”
A SHA-256 digest identifies the bytes you retained. It cannot demonstrate that an omitted companion never existed. Likewise, an integrity check can address structural consistency without proving that every record visible before capture is present in your artifact.
For our exercise, report: “The standalone main-file copy contained zero rows. The source connection and logical backup each contained one committed row at the comparison point. The main-file copy is insufficient for a claim that the source table was empty.”
Use the report template to put the acquisition method beside the query result. If the original capture cannot be reconstructed, preserve that uncertainty rather than turning an incomplete view into a historical conclusion.
Author: OSINT Jet · Primary sources reviewed 22 November 2026
