Fix for sqlite dropping data intermittantly, and add handling for SQLITE_BUSY errors introduced in later sqlite revisions.

Check for SQLITE_BUSY and SQLITE_LOCKED by bitmask, 
and call sqlite3_reset when SQLITE_BUSY is returned. 

Otherwise, data loss is suffered, with no error.