Jump to content

SQLite: Waiting for database to unlock


Recommended Posts

How I can properly wait while SQLite database is busy? I trying to use _SQLite_SetTimeout(-1, 888888) but still get errors:

!   SQLite.au3 Error
--> Function: _SQLite_Exec
--> Query:    DROP TABLE DisplayMemDb.RowRelation;
--> Error:    database table is locked

 

Link to comment
Share on other sites

Without knowledge of the actual situation it's hard to advise.

Is your DB local?
Do you use pragmas? Which? Shared cache?
What is the sequence of all SQL statements raising the error?
Do you use immediate transaction around blocks of Read-Modify-Write queries/commands?
Do you use WAL mode?
Do you use the same timeout on all concurrent connections?
More questions pending...

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

Database is local, pragmas - PRAGMA cache_size = 2 x DB file size

error is raised in :

$sQuery = "SELECT count(Title) FROM SSDB WHERE Title IS '" & $TreeView_SelTitle & "';"
_SQLite_GetTable(-1, $sQuery, $aResult, $iRows, $iColumns)

_SQLite_SetTimeout(-1, 888888)
_SQLite_Exec( -1, "DROP VIEW DisplayView;" )
_SQLite_SetTimeout(-1, 888888)
_SQLite_Exec( -1, "DROP TABLE DisplayMemDb.RowRelation;" )
_SQLite_SetTimeout(-1, 888888)

basically i use code from this post by LarsJ

What i think - maybe _SQLite_GetTable() returning leaving DB in "Locked" state while "Busy" flag is cleared so SetTimeout is not working...

actually this error happens in about 3...5% cases this function is used and not cause any "harm" - just messages in SciTE console, but still...

Link to comment
Share on other sites

Insert error checking after *gettable. Also, escape the litteral string $TreeView_SelTitle. Do you sometimes run some other program(s) using the same DB? There is no reason for *gettable[2d] to not run to completion if the SQL is correct.

Also timeout remains set for a given connection once invoked.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

DB is used only this (one) script

there a no errors after _SQLite_GetTable()

$iRet = _SQLite_GetTable(-1, $sQuery, $aResult, $iRows, $iColumns)
ConsoleWrite("Rows = " & $aResult[2] & "   @error = " & @error & "   _SQLite_ErrMsg(-1) = " & _SQLite_ErrMsg(-1) & @CRLF)

;--------------------------------------------------------------
Rows = 1361   @error = 0   _SQLite_ErrMsg(-1) = not an error

 

Link to comment
Share on other sites

Jeez, I'd like to reproduce that. Can you please post a complete reproducer. If there is any private data, PM it.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...