Question

Is it possible to read from a SQLite db while it's being written to?

I'm aware that access is blocked for writes when it's being written to, but is that the same for reads?

Was it helpful?

Solution 2

After some reading around, and looking through the FMDB code, I discovered that I wasn't using the SQLITE_BUSY and SQLITE_LOCKED return values correctly.

According to the FMDB code, one should loop for a limited number of retries, waiting for a short time bewteen.

So I implemented that in my code, and everything seems to work fine.

OTHER TIPS

It's a little convoluted, but check out the File Locking and Concurrency documentation for SQLite. It sounds like if the db is in exclusive locked mode, that is the only time reads are not allowed. Besides unlocked, when the db is not even open.

I'm not 100% sure on it, but that's what I think it means.

Yes, although all the relevent multithreading issues need to be account for. I generally open multiple handles to the same DB file via sqlite3_open_v2().

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top