On 8 November 2013 18:13, JP <jp.garcia.or...@gmail.com> wrote:

> Hi all,
>
> I'm using a SQLite database, and in my application I have with several
> threads reading/writing. Sometimes I get errors accessing the database,
> probably because one thread tries to read while another is writing. I can
> handle this situation using a mutex. However, there is also an external
> application that works with the same database, and I can not synchronize
> the access in any way between that application and mine. What surprises me
> is that I thought SQLite had a kind of time-out, around 5 seconds, before
> aborting the operation, if there are access problems, but the SOCI methods
> abort the operation instantly, isn't there any time-out? or re-try the
> operation a number of times?
>

You can set the timeout like this (assuming sql is a soci::session):

soci::sqlite3_session_backend * sessionBackEnd =
static_cast<soci::sqlite3_session_backend *>(sql.get_backend());
sqlite_api::sqlite3_busy_timeout(sessionBackEnd->conn_, 1000);

This will set the timeout to 1 second for your session.

Regards,
Felix
------------------------------------------------------------------------------
November Webinars for C, C++, Fortran Developers
Accelerate application performance with scalable programming models. Explore
techniques for threading, error checking, porting, and tuning. Get the most 
from the latest Intel processors and coprocessors. See abstracts and register
http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
_______________________________________________
soci-users mailing list
soci-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/soci-users

Reply via email to