Will pool the connection help threading in sqlite (and how)?

Posted by mamcx on Stack Overflow See other posts from Stack Overflow or by mamcx
Published on 2010-04-08T21:08:03Z Indexed on 2010/04/08 21:13 UTC
Read the original article Hit count: 354

I currently use a singleton to acces my database (see related question) but now when try to add some background processing everything fall apart. I read the sqlite docs and found that sqlite could work thread-safe, but each thread must have their own db connection. I try using egodatabase that promise a sqlite wrapper with thread safety but is very buggy, so I return to my old FMDB library I start to see how use it in multi-thread way.

Because I have all code with the idea of singleton, change everything will be expensive (and a lot of open/close connections could become slow), so I wonder if, as the sqlite docs hint, build a pooling for each connection will help. If is the case, how make it? How know wich connection get from the pool (because 2 threads can't share the connection)?

I wonder if somebody already use sqlite in multu-threading with NSOperation or similar stuff, my searching only return "yeah, its possible" but let the details to my imagination...

© Stack Overflow or respective owner

Related posts about sqlite3

Related posts about objective-c