I'm developing a iOS app using SQLite. I've got a class to manage SQL's operations, basically read, write and update. In many cases I get a SQLITE_BUSY error, so I want know which process is using the database at the moment that the SQLITE_BUSY error occurs. I believe that I'm trying to INSERT data while another process is reading data.
Actually I'm trying handle it like this: (YES, IT'S WRONG)
let aux_error_code = 0
repeat {
if sqlite3_step(insertStatement) == SQLITE_DONE {
lastid = Int(sqlite3_last_insert_rowid(db))
aux_error_code = 0
} else {
aux_error_code = sqlite3_errcode(db)
print("ERRO SQLITE INSERT STEP, ERROR CODE: \(aux_error_code), MSG ERROR: \(sqlite3_errmsg(db)!)\n QUERY: \(insertStatementString)")
}
} while(aux_error_code == 5)
This generate a big list of prints.
SQLite has some ways to handle this, but to choose one I want know what process specifically is causing this problem. I believe that this is a good way to solve my problem: https://www.sqlite.org/c3ref/open.html, but I don't have experience with this. Because that I want know which process causes my problem, if is read or update, or insert by other function too. Anyone can help me to handle this?