lib/sqlite3: store and use the error code of a failed database opening