This is a known problem related to cheap SD/Drives that do not honor sync requests. As the SQLite authors stated:
“USB flash memory sticks seem to be especially pernicious liars regarding sync requests. One can easily see this by committing a large transaction to an SQLite database on a USB memory stick. The COMMIT command will return relatively quickly, indicating that the memory stick has told the operating system and the operating system has told SQLite that all content is safely in persistent storage, and yet the LED on the end of the memory stick will continue flashing for several more seconds. Pulling out the memory stick while the LED is still flashing will frequently result in database corruption...”
Your best defense here is to manually commit your DB as you did (unqlite_commit()), close the database handle (unqlite_close()) and wait a little bit hoping that everything gets **really** flushed to the target surface.