Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Error (RT) in LogErrors: failed. Sqlite error 5
#1
Hello All,
In my Error log, I write to a Sqlite Database file. Occasionally I get this in the QM output, presumably from the function trying to write an error to the Db3 in the LogErrors function: Error (RT) in LogErrors: failed. Sqlite error 5. database is locked. ?

This may be more of a sqlite question than QM, so any Sqliter's out there. I close out my instance of the Db like this:


Code:
Copy      Help
Sqlite ErrorLogDb.Open(ErrorLogDbPath)
ErrorLogDb.Exec(ErrorLogExecFormat)
ErrorLogDb.Close

whenever writing or reading from it in other functions. I thought Sqlite was supposed to be able to handle all these different queries simultaneously.

Any thoughts,
S
#2
Error if multiple threads write simultaneously to the same database. Need to lock.

This test code runs 2 threads that write to the same database. Error if without lock.

Macro Macro1704
Code:
Copy      Help
rep 2
,mac "sqlite_thread"

Function sqlite_thread
Code:
Copy      Help
str dbfile="$desktop$\test.db3"
rep 10
,lock log_err_sqlite "Global\QM_log_err_sqlite"
,Sqlite db1.Open(dbfile)
,db1.Exec("CREATE TABLE IF NOT EXISTS table1 (A,B)")
,db1.Exec(F"INSERT INTO table1 VALUES ('one','two')")
,db1.Close
,lock- log_err_sqlite
#3
Thanks...this is extremely helpful!
Stuart


Forum Jump:


Users browsing this thread: 1 Guest(s)