This seems to fly in thte face of what I remember reading on here before.  Can 
we get a clear explanation of what to do with the different THREADSAFE 
settings?  I think it's implied...



i.e. (assumign this is correct)

Single-thread -- no threading allowed at all

Multi-thread -- one sqlite3 object per thread is required -- no sharing of 
prepared statements or anything else.

Serialized -- sqlite3 object can be shared among threads along with prepared 
statements and all other functions.



Michael D. Black

Senior Scientist

Advanced Analytics Directorate

Advanced GEOINT Solutions Operating Unit

Northrop Grumman Information Systems

________________________________
From: sqlite-users-boun...@sqlite.org [sqlite-users-boun...@sqlite.org] on 
behalf of Pavel Ivanov [paiva...@gmail.com]
Sent: Tuesday, May 29, 2012 8:08 AM
To: 吴 毅; General Discussion of SQLite Database
Subject: EXT :Re: [sqlite] How to write and read the same sqlite3 DB in memory 
concurrently in two thread?

> How to write and read the same sqlite3 DB in memory concurrently in two 
> thread?

You need to use one connection (sqlite3 object) and not to use
SQLITE_OPEN_NOMUTEX flag (assuming you used default SQLite compilation
options) or protect access to sqlite3 object with your own mutex.


Pavel


On Fri, May 25, 2012 at 4:51 AM, 吴 毅 <wuyiy...@yahoo.com.cn> wrote:
> Now I am writing datas to sqlite3 DB in memory(":memory:") in a thread .
> And concurrently I want to read the datas of the same DB in memory too.
> but While i used the same object of sqlite3 to write and read, i had got the 
> error:SQLITE_MISUSE.
> If i use the different objects of sqlite3 to write and read 
> concurrently,these objects get the different DB in memory.This is not I want 
> to do.I want to get datas of the same database.
> Moreover, I don't plan to write and read the database in disks too.Becase I 
> thick it's more faster to operate in memory.
> I open the database in the way of "m_sqliteDB.open(":memory:");" now.
>
> How to write and read the same sqlite3 DB in memory concurrently in two 
> thread?
>
> That might be?
>
> thank you.
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to