从
Wikipedia page:
Several computer processes or threads may access the same database without problems. Several read accesses can be satisfied in parallel.
更确切地说,从FAQ:
Multiple processes can have the same database open at the same time. Multiple processes can be doing a SELECT at the same time. But only one process can be making changes to the database at any moment in time,however.
然而,对数据库的单个写入会锁定数据库一段时间,所以没有什么可以访问它(甚至没有读取)。详细信息可以在File Locking And Concurrency In SQLite Version 3找到。基本上读取数据库没有问题,除非有人想立即写入数据库。在这种情况下,DB在执行该事务所需的时间内被独占锁定,并且该锁随后被释放。然而,关于在PENDING或EXCLUSIVE锁定的时候对数据库的读取操作究竟是什么的细节是很少的。我的猜测是,他们或者返回sqlITE_BUSY或阻塞,直到他们可以读取。在第一种情况下,不应该太难以再次尝试,特别是如果你期望几乎没有写入。