Igor Tandetnik wrote:
> "Karthik" <[EMAIL PROTECTED]> wrote in
> message news:[EMAIL PROTECTED]
>   
>> Newbie question regarding in-memory databases. I read in the wiki
>> pages that it is not safe to use same db connection across multiple
>> threads.
>>     
>
> It's actually safe with recent SQLite versions. A lot of issues have 
> been eliminated. SQLite know uses a mutex to serialize concurrent API 
> calls from multiple threads.
>
> You have to know what you are doing of course. E.g. if one thread starts 
> a transaction, then another thread issues some statements, they go into 
> that transaction.
>
>   
>> I am trying to use an in-memory database. My understanding
>> is that opening a connection with ":memory:" creates the database and
>> closing it erases the same. If I were to use one connection per
>> thread will i end up creating distinct memory db's for each thread?
>>     
>
> Yes.
>
>   
>> is it possible to use a single in-memory db that can be accessed by
>> different threads in a multithreaded environment?
>>     
>
> The only way is to pass the same db connection between threads.
>
> Igor Tandetnik
>
>
>
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
>   
Thank you! I did try passing around the connection across threads(before 
reading the wiki at 
http://www.sqlite.org/cvstrac/wiki?p=MultiThreading), and things seemed 
to work without any trouble. Thanks again for clarifying.
Another question about in-memory databases. I have a producer-consumer 
sort of application, different threads keep on updating data in a table 
and after a scheduled interval, i extract aggregated data from the table 
and clean up the table, and in the worst cases the producers may flood 
the db before the cleanup happens,
is it possible to set a limit on the database size? how does sqlite 
behave when database size reaches the threshold(the default/configured one)?
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to