Jump to content

sqlite3.exe dot command example


Recommended Posts

; works Local $sqlCLI = 'sqlite3.exe C:/Users/AppData/Local/Temp/~knakvog.tmp ".read sql2csv.txt" '
                Local $sqlCLI = 'sqlite3.exe C:/Users/AppData/Local/Temp/~knakvog.tmp < xpt2csv.txt '

                Local $openCSV = Run(@ComSpec & " /k " & $sqlCLI,@ScriptDir,@SW_HIDE)

Much less impressive than I hoped for.

Change the @SW_HIDE to MAX to see the results of the labour. 

It appears as if SQLITE3.EXE can accept one argument after the dbfile name, so the ".read..." works.  But it does not allow multiple consecutive parameters.

-- sql text file content sql2.csv.txt
.headers on
.mode csv
.once dataout.csv
SELECT * FROM memCSV;
.system dataout.csv
.quit

The above line reads the 'sql2csv.txt' file using either of the "< or .read" options, and executes correctly.

Trying to stipulate all in the AutoIt command line results in failure

Line below does NOT work. 

; not working Local $sqlCLI = 'sqlite3.exe "C:/Users/AppData/Local/Temp/~knakvog.tmp" ".headers on" ".mode csv" ".once dataout.csv" SELECT * FROM memCSV; ".system dataout.csv"  '

Failure appears to be a native SQLITE3 "too many parameters" issue and not related to AutoIt.  

Edited by Skysnake
improved

Skysnake

Why is the snake in the sky?

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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By AndyS01
      When I try to open a SQLite database, the script exits within the _SQLite_Open() function.
      I have debugged the code in SQLite3.au3 and the culprit is the DLL call to xx.  Specifically to this code:
      Local $avRval = DllCall($__g_hDll_SQLite, "int:cdecl", "sqlite3_open_v2", "struct*", $tFilename, _ ; UTF-8 Database filename "ptr*", 0, _ ; OUT: SQLite db handle "int", $iAccessMode, _ ; database access mode "ptr", 0) Using ConsoleWrite() calls, I have determined that the script makes it to the DLLCall, but exits without returning from it.  I have examined the DLL file and I see the sqlite3_open_v2 entry.
      Here is my test code:
      #include <SQLite.au3> _Main() Func _Main() _SQLite_Startup("winSQLite3.dll") If @error Then MsgBox(0, "SQLite Error", "SQLite3.dll Can't be Loaded!") Exit -1 EndIf ConsoleWrite("- _SQLite_LibVersion = " & _SQLite_LibVersion() & @CRLF) _SQLite_Open() ; Creates a :memory: database and don't use its handle to refer to it ConsoleWrite("-" & @ScriptLineNumber & ": HERE" & @CRLF) If @error Then MsgBox(0, "SQLite Error", "Can't create a memory Database!") Exit -1 EndIf _SQLite_Close() ConsoleWrite("-" & @ScriptLineNumber & ": HERE" & @CRLF) _SQLite_Shutdown() EndFunc ;==>_Main  
    • By Colduction
      Hi everyone! i have Two-Problems:
      I've used this code to decode and export cookies from Google Chrome application's "C:\Users\%username%\AppData\Local\Google\Chrome\User Data\Default\Cookie" file but i can't receive any data: #include <CryptProtect.au3> #include <SQLite.au3> #include <SQLite.dll.au3> Global Const $g_sLoc_Output = @ScriptDir & "\Cookies.txt" If FileExists($g_sLoc_Output) Then FileDelete($g_sLoc_Output) EndIf $hFO_Output = FileOpen($g_sLoc_Output ,1) If $hFO_Output <> -1 Then FileWrite($hFO_Output, Chrome()) FileFlush($hFO_Output) FileClose($hFO_Output) EndIf Func Chrome() Local $q, $r, $sOutput, $sLoc_ChromeDB = EnvGet("localappdata") & "\Google\Chrome\User Data\Default\Cookies" If FileExists($sLoc_ChromeDB) = False Then Return "" _SQLite_Startup() If @error Then MsgBox(16, "SQLite Error", "SQLite3.dll Can't be Loaded! - " & $__g_hPrintCallback_SQLite & @CRLF & @CRLF & "Exiting application") Exit -1 EndIf _SQLite_Open($sLoc_ChromeDB) _SQLite_Query(-1, 'SELECT host_key, name, value, encrypted_value FROM cookies', $q) While _SQLite_FetchData($q, $r) = 0 $sOutput = $sOutput & r[0] & @CRLF & r[1] WEnd _SQLite_Close() _SQLite_Shutdown() Return $sOutput EndFunc I've used this code too for decrypt my saved passwords and export from Google Chrome application's "C:\Users\%username%\AppData\Local\Google\Chrome\User Data\Default\Login Data" file but i can't get decrypted data: #include <CryptProtect.au3> #include <SQLite.au3> #include <SQLite.dll.au3> Global Const $g_sLoc_Output = @ScriptDir & "\Credentials.txt" If FileExists($g_sLoc_Output) Then FileDelete($g_sLoc_Output) EndIf $hFO_Output = FileOpen($g_sLoc_Output ,1) If $hFO_Output <> -1 Then FileWrite($hFO_Output, Chrome()) FileFlush($hFO_Output) FileClose($hFO_Output) EndIf Func Chrome() Local $q, $r, $sOutput, $sLoc_ChromeDB = EnvGet("localappdata") & "\Google\Chrome\User Data\Default\Login Data" If FileExists($sLoc_ChromeDB) = False Then Return "" _SQLite_Startup() If @error Then MsgBox(16, "SQLite Error", "SQLite3.dll Can't be Loaded! - " & $__g_hPrintCallback_SQLite & @CRLF & @CRLF & "Exiting application / Zavolej Honzovi") Exit -1 EndIf _SQLite_Open($sLoc_ChromeDB) _SQLite_Query(-1, "select * from logins;", $q) While _SQLite_FetchData($q, $r) = 0 $sOutput = $sOutput & "======================| " & $r[7] & " |======================" & @CRLF & "Login URL: " & $r[0] & @CRLF & "Email/User: " & $r[3] & @CRLF & "Password: " & _CryptUnprotectData($r[5], "") & @CRLF & @CRLF WEnd _SQLite_Close() _SQLite_Shutdown() Return $sOutput EndFunc Thanks!
    • By Skeletor
      Hi All,
      Here's a really simple question. 
      I ran the code from the helpfile under: _SQLite_Open

      Issue is I end up with an error message: SQLite3.dll Can't be Loaded!
      I placed the *.dll in the include folder, but still nothing. 

      Where must this file be placed.
       
    • By jvds
      when i try to run my code i get the folowing error
      @@ Debug(257) : __SQLite_Download_SQLite3File : $URL = http://www.autoitscript.com/autoit3/files/beta/autoit/archive/sqlite/sqlite3.dll
          $sTempfile = C:\DOCUME~1\user\CONFIG~1\Temp\~hdyarac.dll
      >Error: 13
      #include <SQLite.au3> #include <SQLite.dll.au3> Local $aResult, $iRows, $iColumns, $iRval Local $hFile, $vData, $sFileName, $sData, $hQuery, $aRow, $sMsg _SQLite_Startup() ConsoleWrite("_SQLite_Startup" & @LF) ;~ ConsoleWrite("_SQLite_LibVersion=" & _SQLite_LibVersion() & @CRLF) Local $sqldb = _SQLite_Open('DB')only on a WinXP computer, it works on win7, any idea what it may be?
    • By Skysnake
      Hi
      Could not find the sqlite3_progress_handler in the AutoIt Forum.
      SQLITE link is here https://www.sqlite.org/c3ref/progress_handler.html (sorry, LINK insert not working)
      I wrote the code below based on examples from the SQLITE.AU3 include.  I do not understand the possible errors.  Also, I am not familiar with the the "C" syntax.
      Comments and improvements are greatly appreciated.
      Func _SQLite_Progress($hDB = -1, $iTimer = 1000,$sCallback = "_cb",$Param = 1) If __SQLite_hChk($hDB, 2) Then Return SetError(@error, 0, $SQLITE_MISUSE) If $iTimer = Default Then $iTimer = 1000 If $sCallback = Default Then $sCallback = "_cb" If $Param = Default Then $Param = 1 Local $avRval = DllCall($__g_hDll_SQLite, "int:cdecl", "sqlite3_progress_handler", _ "ptr", $hDB, _ ; D An open database connection "int", $iTimer, _ ; N the number of virtual machine instructions to evaluate between successive callbacks "int", $sCallback, _ ; X user defined callback function "ptr", $Param) ; P only parameter passed to callback X If @error Then Return SetError(1, @error, $SQLITE_MISUSE) ; DllCall error If $avRval[0] <> $SQLITE_OK Then SetError(-1) Return $avRval[0] EndFunc ;==>_SQLite_SetTimeout  
×
×
  • Create New...