On Fri, 14 Jun 2013, Richard Hipp might have said: > On Fri, Jun 14, 2013 at 9:10 AM, Vijay Khurdiya < > [email protected]> wrote: > > > Please confirm below statement is TRUE when Sqlit3 configure in thread > > safe mode. (I am checking for Serialized) > > > > "Multiple processes can access same database connection"? > > > > False. > > A "database connection" is an in-memory object that communicates with an > SQLite database file. The operating system prevents multiple processes > from accessing the same memory, so it is not possible for multiple > processes to access the same database connection. > > Perhaps you meant to ask if multiple processes could access the same SQLite > database file at the same time. The answer to that question is "yes". > > An SQLite "database connection" is analogous to the FILE* handle of > fopen(). You can fopen() the same file at the same time from multiple > processes. Each process has its own private FILE* handle, but all FILE* > handles point to the same file on disk. In the same say, each process > using sqlite3_open() will have its own database connection, but all the > database connections will be accessing the same database file. > > Don't take this analogy too far, however. When multiple processes open the > same file using fopen(), they can overwrite one another and cause all kinds > of mischief. But SQLite employs file locking to prevent writes by one > process from interfering with the other processes and to insure that the > database stays consistent, even if some of the connecting processes > misbehave or crash.
I've read of multiple processes opening the same database. How far can this go? Is it allowed to have one writer and many readers or can each process be writer and reader? I am thinking of having one process web facing, when a request comes from the web the web facing process writes a record to a transaction table. Another process waits for work in the transaction table, removes a record from that transaction table, and does the requested work. Does that make sense and is that possible? Both processes would write to the datbase file. Mike _______________________________________________ sqlite-users mailing list [email protected] http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

