On 21 Jun 2018, at 10:01pm, Phani Rahul Sivalenka
<[email protected]> wrote:
> When we do a read operation and write/update operation on the SQLite DB,
> the write operation gets timed out saying the “db is locked”.
[...]
> - Busy Timeout : 30sec
> - Default Timeout : 30sec
I'm going to assume you're doing something like
SQLiteConnectionStringBuilder connBuilder = new SQLiteConnectionStringBuilder();
connBuilder.Version = 3;
connBuilder.DataSource = filePath;
connBuilder.BusyTimeout = 30;
connBuilder.DefaultTimeout = 30;
If this isn't what you're doing please tell us.
SQLite itself uses busyTimeout. The unit of busyTimeout is milliseconds. Try
setting the value to 30000 and see if this fixes your problem. I don't know
what defaultTimeout means to the library you're using but try doing the same
thing with that one.
How are you disposing of your SQLiteDataReader object after the reading is
finished ? Once the object has locked the file, while it still exists it can
maintain a lock on the file. One way to make sure that the object has been
disposed of is to use this structure:
using (SQLiteCommand cmd =
new SQLiteCommand("SELECT * FROM sqlite_master;", cnn)) {
using (SQLiteDataReader reader = cmd.ExecuteReader()) {
// extract data from reader so you don't need it any more
}
}
You will need to dispose of your writing object too. Possibly in a similar way.
Simon.
_______________________________________________
sqlite-users mailing list
[email protected]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users