SQLite.exe not found (yet exists!)

5 posts in this topic


I'm trying to create an SQLite database.
After Importing 2 csv files I'm creating a new tabel and trying to export this table to a new file.


Now I think I'm pretty close, but the code seems buggy.
It's telling (50% of the time) me sqlite3.exe is not found.
Yet, it absolutely exist in the @scriptdir.

Please help?


#include <File.au3>
#include <SQLite.au3>
#include <SQLite.dll.au3>
#include <StringConstants.au3>

; Filenames
Local $sTsvFile_new = FileGetShortName(@DesktopDir & "\HGSwijzgingen_new.csv")
Local $sTsvFile_oud = FileGetShortName(@DesktopDir & "\HGSwijzgingen_oud.csv")
Local $sDbFile = @ScriptDir & "\ArtLev.db"

;  ==  CREATE Table NEW  ==
; import (using SQLite3.exe)
Local $sIn, $sOut, $i, $sCreate = "CREATE TABLE TblImportNEW (";
For $i = 1 To _StringCountOccurance(FileReadLine($sTsvFile_new, 1), ";") + 1
    $sCreate &= "Column_" & $i & ","
$sCreate = StringTrimRight($sCreate, 1) & ");"
$sIn = $sCreate & @CRLF ; Create Table
$sIn &= ".separator \;" & @CRLF ; Select @TAB as Separator
$sIn &= ".import '" & $sTsvFile_new & "' TblImportNEW" & @CRLF
_SQLite_SQLiteExe($sDbFile, $sIn, $sOut, -1, True)

;  ==  CREATE Table OUD  ==
; import (using SQLite3.exe)
Local $sIn, $sOut, $i, $sCreate = "CREATE TABLE TblImportOUD (";
For $i = 1 To _StringCountOccurance(FileReadLine($sTsvFile_oud, 1), ";") + 1
    $sCreate &= "Column_" & $i & ","
$sCreate = StringTrimRight($sCreate, 1) & ");"
$sIn = $sCreate & @CRLF ; Create Table
$sIn &= ".separator \;" & @CRLF ; Select @TAB as Separator
$sIn &= ".import '" & $sTsvFile_oud & "' TblImportOUD" & @CRLF
_SQLite_SQLiteExe($sDbFile, $sIn, $sOut, -1, True)

; == JOIN QUERY SQLite ==
Dim $hQuery
Dim $SQlite_Qry = 'CREATE Table HGSwijzigingen AS SELECT TblImportNEW.Column_1 AS "ART", TblImportNEW.Column_2 AS "OMSCHRIJVING", TblImportNEW.Column_3 AS "NEW", TblImportOUD.Column_3 AS "OLD" FROM TblImportNEW LEFT JOIN TblImportOUD  ON TblImportNEW.Column_1 = TblImportOUD.Column_1 WHERE TblImportOUD.Column_3 <> TblImportNEW.Column_3;'
_SQLite_SQLiteExe($sDbFile, $SQlite_Qry, $sOut, -1, True)

;  CREATE JOIN Table and import as Array for export to file.
If @error = 0 Then
    ;Show Table (using SQLite3.dll)
    Local $iRows, $iColumns, $aRes
    ConsoleWrite("_SQLite_LibVersion=" & _SQLite_LibVersion() & @CRLF)

    _SQLite_GetTable2d(-1, "SELECT ROWID,* FROM TblImportNEW WHERE Column_1 = '9899820';", $aRes, $iRows, $iColumns)
    _SQLite_Display2DResult($aRes) ; Output to Console

    _SQLite_GetTable2d(-1, "SELECT * FROM HGSwijzigingen';", $aRes, $iRows, $iColumns)

    If @error = 2 Then
        ConsoleWrite("ERROR: Sqlite3.exe file not found" & @CRLF)
        ConsoleWrite("ERROR: @error=" & @error & " when calling _SQLite_SQLiteExe" & @CRLF)

Func _StringCountOccurance($sSearchString, $sSubString, $iCaseSense = $STR_NOCASESENSE) ; Returns Number of $sSubString in $sSearchString
    Local $iOccCnt = 1
        If StringInStr($sSearchString, $sSubString, $iCaseSense, $iOccCnt) > 0 Then
            $iOccCnt += 1
    Until 0
    Return $iOccCnt - 1
EndFunc   ;==>_StringCountOccurance
>"C:\Users\T12037\OneDrive - SONEPAR\PortableApps\AutoIt\install\SciTE4AutoIt3_Portable\..\AutoIt3.exe" "C:\Users\T12037\OneDrive - SONEPAR\PortableApps\AutoIt\install\SciTE4AutoIt3_Portable\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "C:\Users\T12037\OneDrive - SONEPAR\Scripts\SQLite\SQLite_SQLiteExe_v1.0.au3" /UserParams    
+>10:58:22 Starting AutoIt3Wrapper v.16.306.1237.0 SciTE v.   Keyboard:00020409  OS:WIN_10/  CPU:X64 OS:X64  Environment(Language:0413)  CodePage:0  utf8.auto.check:4    # detect ascii high characters and if none found set default encoding to UTF8 and do not add BOM
+>         SciTEDir => C:\Users\T12037\OneDrive - SONEPAR\PortableApps\AutoIt\install\SciTE4AutoIt3_Portable   UserDir => C:\Users\T12037\OneDrive - SONEPAR\PortableApps\AutoIt\install\SciTE4AutoIt3_Portable\AutoIt3Wrapper
>Running AU3Check (  from:C:\Users\T12037\OneDrive - SONEPAR\PortableApps\AutoIt\install  input:C:\Users\T12037\OneDrive - SONEPAR\Scripts\SQLite\SQLite_SQLiteExe_v1.0.au3
+>10:58:22 AU3Check ended.rc:0
>Running:(\Users\T12037\OneDrive - SONEPAR\PortableApps\AutoIt\install\autoit3_x64.exe "C:\Users\T12037\OneDrive - SONEPAR\Scripts\SQLite\SQLite_SQLiteExe_v1.0.au3"    
--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop
ERROR: Sqlite3.exe file not found
+>10:58:40 AutoIt3.exe ended.rc:0
+>10:58:40 AutoIt3Wrapper Finished.
>Exit code: 0    Time: 18.96


Share this post

Link to post
Share on other sites

#2 ·  Posted (edited)

Did you try to remove the 

#include <SQLite.dll.au3>

, using the path of the sqlite3.exe ( in your current @ScriptDir ) as parameter when you call _SQLite_SQLiteExe() function, downloadable from here?


Edited by FrancescoDiMuro

Click here to see my signature:


I will always thank you for the time you spent for me.
I'm here to ask, and from your response, I'd like to learn.
By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

Share this post

Link to post
Share on other sites

I don't think that's the answer for me.
It seems like the first ** CREATE TABLE ** works fine, after that the code crashes.
Maybe it's locking the SQLite3.exe so it can't be used / called again?

Share this post

Link to post
Share on other sites

I see in the name you are using a OneDrive directory. Could that be re reason it is giving issues where OneDrive is locking files?
Also see you are running the X64 version of AutoIt3, maybe something to try and run the x86 version?


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
Live for the present,
Dream of the future,
Learn from the past.

Share this post

Link to post
Share on other sites

Jos, looks like ONEDRIVE is the problem here.
Changing the output to C:\ has given me no errors except when de original SQLite.db already exists.

So it seems ONEDRIVE is just to slow to keep up.


Share this post

Link to post
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