In order for this site to work correctly we need to store a small file (called a cookie) on your computer. Most every site in the world does this, however since the 25th of May 2011, by law we have to get your permission first. Please abandon the forum if you disagree.

Para que este foro funcione correctamente es necesario guardar un pequeño fichero (llamado cookie) en su ordenador. La mayoría de los sitios de Internet lo hacen, no obstante desde el 25 de Marzo de 2011 y por ley, necesitamos de su permiso con antelación. Abandone este foro si no está conforme.

Sqlite : Concurrent User Problem

Xailer English public forum
Responder
Milan Mehta
Mensajes: 140
Registrado: Dom Dic 27, 2009 9:54 am

Sqlite : Concurrent User Problem

Mensaje por Milan Mehta »


What is the standard procedure to be followed in the cases where concurrent users try to save data in Sqlite database ?
Quite often we get the error : Database is locked [#5].
TIA
Milan.
Avatar de Usuario
ignacio
Site Admin
Mensajes: 9440
Registrado: Lun Abr 06, 2015 8:00 pm
Ubicación: Madrid, Spain
Contactar:

Sqlite : Concurrent User Problem

Mensaje por ignacio »

Hello,
SQLite always locks the complete database on every update operation. In order to reduce your problem I suggest the following:
1) Use always transactions
2) Use Memdatasets instead of SQLite datasets when no edit is needed. Since sort & filter operations are done internally
3) Set oSqlite:lAllowProcessMessages to false
Regards,
Ignacio Ortiz de Zúñiga
[OZ Software]
https://www.ozs.es
--
[Equipo de Xailer / Xailer team]
https://www.xailer.com
Avatar de Usuario
emeasoft
Mensajes: 1094
Registrado: Mié Abr 01, 2009 4:12 pm
Ubicación: emeasoft
Contactar:

Sqlite : Concurrent User Problem

Mensaje por emeasoft »

Bom dia,
Estamos migrando de DBF para SQLite e encontramos o mesmo problema de compartilhamento do banco de dados quando o
sistema está rodando em rede.
Para solucionar isto desenvolvemos a rotina abaixo que funciona igual ao Flock e Neterr:
No iní­cio do aplicativo:

::oSQLite:cConnect:="TESTE.bd"
::oSQLite:lConnected :=.T.
::oSQLite:lAbortOnErrors:=.F.
::oSQLite:lAllowProcessMessages:=.T.
::oSQLite:lDisplayErrors:=.F.
::oSQLite:lReadToCache := .T.
::oSQLite:cPassword:="123456"
::oSQLite:Execute("PRAGMA busy_timeout = 5000")

Nas rotinas:

DO WHILE .T.
::oLabel:cText:="Aguardando gravação...."
IF !::oSQLite:lConnected
::oSQLite:lConnected :=.T.
ENDIF
::oSQLite:Execute("REPLACE INTO ......
IF !::oSQLite:IsError()
::oLabel:cText:="Gravado...."
EXIT
ELSE
::oSQLite:DelErrors()
Sleep(200)
ENDIF
ENDDO

Aguardamos novas soluçíµes se existir.
Abraços
Mário Angelini
Avatar de Usuario
emeasoft
Mensajes: 1094
Registrado: Mié Abr 01, 2009 4:12 pm
Ubicación: emeasoft
Contactar:

Sqlite : Concurrent User Problem

Mensaje por emeasoft »

Hello Xailers,
Is there a way to change the locktype or lock only the table?
Because we can't even use a "select" when updating a table.... the entire database is locked.
TIA,
Juliano
Responder