Page 1 of 1

Shared Cache Mode or Unlock Notification

Posted: Fri 30 Aug 2013 14:05
by ML_hQ
Hello Devart-Team,

I'm trying to handle multiple connections to a single database. My problem is the "database is locked" ESQLiteError, which occurs whenever the database is exclusively locked (during writing). According to the SQLite homepage (www.sqlite.org) there are two possibilities for me:

1. Unlock Notify (http://sqlite.org/c3ref/unlock_notify.html)
Using Unlock Notify would enable me to queue my posts and solving the problem smoothly.
Is there a simple implementation for this in DBExpress? Could you give me a code sample for it? And is there a disadvantage (besides the ones listed on the homepage) by using Unlock Notify?

2. Shared Cache Mode (http://www.sqlite.org/sharedcache.html)
I'm not sure if this would fix my problem, but I'm willing to try it. As we are using multiple database types over DBExpress, I can't use the TSQLiteConnection. Instead I'm using the TSQLConnection from SqlExp.pas. Is there a possibilty to use Shared Cache Mode with this kind of connection? Or does it only work with the TSQLiteConnection?

Thanks in advance an best regards
Markus

Re: Shared Cache Mode or Unlock Notification

Posted: Fri 30 Aug 2013 15:30
by AlexP
Hello,

For the time being, we don't support Unlock Notification, since the standard SQLite library available at the developers website is compiled without support for this functionality.
Yes, you can use the Shared Cache mode. For this, you should set the TSQLConnection EnableSharedCache property to True (see Readme.html)

Re: Shared Cache Mode or Unlock Notification

Posted: Mon 02 Sep 2013 13:16
by ML_hQ
Thank you for your help!

The EnableSharedCache property can't be set for TSQLConnection, as it is an TSQLiteConnection exclusive property.

But using the ReadMe I found another solution:

Code: Select all

SQLConnection1.SQLConnection.SetOption(coEnableSharedCache, integer(True));
This seems to work. I'll have to run some more tests before I can definitely say if the problem is fixed.