For the record, I fixed it with sqlitebrowse, using the "Compact Database" option. I replaced the database with the compacted one and nobody complained

I guess this is the same Kobo Utilities does when compressing the database, but I didn't try (and I suspect it would also refuse to do it if the database does not pass the integrity check to start with).