Using TLiteConnection from threads

Discussion of open issues, suggestions and bugs regarding LiteDAC (SQLite Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Max Terentiev
Posts: 20
Joined: Sun 05 Jun 2016 17:11

Using TLiteConnection from threads

Post by Max Terentiev » Fri 09 Sep 2016 01:13

Hi,

Can I use one TLiteConnection from multiple threads in same time without any synchronization in my code (TCriticalSection, Synchronize, etc) ? Or I must create separate TLiteConnection in each thread ? Can't find anything about it in Help file.

And second question: should I use TLiteConnection.Options.EnableSharedCache for best perfromance if I read/write to database from threads ?

Thanks for help !

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Using TLiteConnection from threads

Post by AlexP » Fri 09 Sep 2016 13:31

Hello,

Yes, LiteDAC allows working with SQLite in threads: for parallel access to a DB from different threads, extended options were added to delimit simultaneous access to a DB: BusyTimeout, EnableSharedCache, ReadUncommitted. You can find more detailed information on these options in the LiteDAC help.

P.S. Moreover, SQLite thread-safety depends on the value of the SQLITE_THREADSAFE option, that was set when building the SQLite library. In the Direct mode, we use the value "1" supposing full thread-safety.You can refer to the SQLite developers site for more detailed information: http://www.sqlite.org/compile.html#threadsafe ,
http://www.sqlite.org/threadsafe.html .

Post Reply