Hello
Code: Select all
; main thread opens the database like this:
activeSQLdb := new SQLiteDB
If !activeSQLdb.OpenDB(fileName)
Return -1
; each thread opens the database in this manner:
activeSQLdb := new SQLiteDB
If activeSQLdb.OpenDB(sqlDBfile, "R", 0)
ExitApp
; each thread executes this loop:
Loop, % count
retrieveSQLdbEntryImgHisto(filesArray[A_Index, 1])
; ===================
retrieveSQLdbEntryImgHisto(fullPath, imgIndex) {
RecordSet := ""
SplitPath, fullPath, fileNamu, imgPath
activeSQLdb.EscapeStr(imgPath)
activeSQLdb.EscapeStr(fileNamu)
SQL := "SELECT imgmedian, imgavg, imghpeak, imghlow FROM images WHERE (imgfile=" fileNamu " AND imgfolder=" imgPath ");"
If !activeSQLdb.Query(SQL, RecordSet)
Return 0
obju := []
Loop
{
If (Row[1] || Row[2] || Row[3])
{
obju.median := Row[1]
obju.avg := Row[2]
obju.peak := Row[3]
obju.low := Row[4]
}
RC := RecordSet.Next(Row)
} Until (RC<1)
RecordSet.Free()
if (obju.median>0 || obju.avg>0 || obju.peak>0)
{
filesArray[imgIndex, 2] := obju
} Else
{
; load image file and blah blah
}
}
Please note, single threaded, i never experienced crashes.
The database is created in a different session with this structure:
Code: Select all
activeSQLdb := new SQLiteDB
activeSQLdb.OpenDB(newFileNamu)
SQL := "CREATE TABLE images (imgfile TEXT COLLATE NOCASE, imgfolder TEXT COLLATE NOCASE, fsize NUMERIC, fmodified NUMERIC, fcreated NUMERIC, imgwidth NUMERIC, imgheight NUMERIC, imgframes NUMERIC, imgpixfmt TEXT, imgmedian NUMERIC, imgavg NUMERIC, imghpeak NUMERIC, imghlow NUMERIC, PRIMARY KEY(imgfolder ASC, imgfile ASC));"
SQL .= "CREATE TABLE imagesData (imgfile TEXT COLLATE NOCASE, imgCaption TEXT, imgAudio TEXT COLLATE NOCASE, PRIMARY KEY(imgfile ASC));"
SQL .= "CREATE TABLE dynamicfolders (imgfolder TEXT COLLATE NOCASE, fmodified NUMERIC, PRIMARY KEY(imgfolder ASC));"
SQL .= "CREATE TABLE staticfolders (imgfolder TEXT COLLATE NOCASE, fmodified NUMERIC, PRIMARY KEY(imgfolder ASC));"
SQL .= "CREATE TABLE settings (paramz TEXT COLLATE NOCASE, valuez TEXT COLLATE NOCASE, PRIMARY KEY(paramz ASC, valuez ASC));"
If !activeSQLdb.Exec(SQL)
Return activeSQLdb.ErrorMsg
The main database for tests contains 350 000 records, but i can create others smaller or bigger...
The purpose is: cache data collected from images [done, works fine] and then when needed, reuse it such that the files are not reloaded again - to have everything go much faster. The issue arrises when I spawn new instances to ping the database to see if the infos are cached or not.
Best regards, Marius.