How can I verify that a SQLite db3 file is valid/consistent
I think you want to try:
pragma integrity_check;
From the documentation:
This pragma does an integrity check of the entire database. The integrity_check pragma looks for out-of-order records, missing pages, malformed records, missing index entries, and UNIQUE and NOT NULL constraint errors. If the integrity_check pragma finds problems, strings are returned (as multiple rows with a single column per row) which describe the problems. [...]
See also the PRAGMA quick_check command which does most of the checking of PRAGMA integrity_check but runs much faster.