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
.system dataout.csv

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


Why is the snake in the sky?

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

  • Similar Content

    • jvds
      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?
    • Skysnake
      By Skysnake
      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