> Hello, > > Maybe many others have asked this question, so I will say sorry if > that's true. > I have a program which uses threads, when writing to (sometime even > reading > from) SQLite, I always got the error of database is locked. > I think since SQLite is a file db, so it get locked easily by multi- > threads or multi-processes. > But is there a way to resolve this problem instead of switching > database to another one? > > Thanks.
I used to have similar problems and solved it by following advice I got on this list, which is to start the transaction with: BEGIN IMMEDIATE; any time the database will be written to (ie an insert, update, delete, etc). That, along with looping on sqlite3_prepare_v2 and sqlite3_step any time you get SQLITE_BUSY, virtually solved the issue for me. HTH Doug _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users