randallc Posted December 17, 2005 Posted December 17, 2005 Hi, Any developments here? I have my sorting OK for limited group sorting for huge files. I will post later. 1. Is SQLite still the way to go?; I see there may be other SQLs which can do a "bulk insert" to get a csv file in quickly; seems to be an issue in SQLite of any wrapper? 2. Which SQLite version now? 3. Any thoughts further on including any in AutoIt? 4. @ptrex, have you tried to get ListView working in "snippets" according to latests sort, so the limited view is not just beginning or end? I don't look forward to it, and won't do it if you have already done so. 5. @ptrex , any further enhancements for @blink database? Best, Randall ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW
piccaso Posted December 17, 2005 Posted December 17, 2005 i'm still working on it (doc's) CoProc Multi Process Helper libraryTrashBin.nfshost.com store your AutoIt related files here!AutoIt User Map
Walkabout Posted December 17, 2005 Posted December 17, 2005 Been poking around as part of some preliminary work for a major piece of development work I'm going do for myself and I've come up with a major limitation (for this case) of SQLite. Database level locking! Means I can't have one script inserting data at the same time as I have another script selecting it. This obviously wouldn't matter for simple, single user applications, but anything more complex will need to use a database with row level locking. Speaking of which, Firebird looks pretty good. Anyone done any work on connecting to a Firebird database using the client DLL (like the SQLite stuff here), rather than using ODBC? Walkabout. My Stuff:AutoIt for the MassesWait until Oracle Apps is readySend email natively from Autoit3
piccaso Posted December 17, 2005 Posted December 17, 2005 (edited) AFAIK only table's get locked... the '_SQlite_Query*' func's handle '%SQLITE_BUSY' stuff themself. and sqlite is pretty fast so it shouldnt be locked for long... i didnt know that firebird had a client dll sounds interesting [edit] the upx'ed firebird dll is only 600k small i didnt find doc's on apicalls (jet) but it looks like a good alternative. Edited December 18, 2005 by piccaso CoProc Multi Process Helper libraryTrashBin.nfshost.com store your AutoIt related files here!AutoIt User Map
randallc Posted December 18, 2005 Posted December 18, 2005 Hi,@piccaso, I'd love to be able to "Split" a huge db so I can keep the sqlite3.exe speed; as it slows down disproportionately after about 100,000 rows in my example; (presumably a memory issue)I can't get it to work, and don't understand why;; I can split it, but no quicker; I think because I don't understand the memory/ stout/ tempfiles/ filewriting of your command when it gets output.Can you please help?This is as close as i can come; $f=FileOpen($sFile,1) For $j = 0 To $TotalRandomRowsINT $BaseStringLength=$MaxStringLength*$j if ($TotalRandomRows>($MaxStringLength*($j -1))) then ;MsgBox(0,"","$MaxStringLength="&$MaxStringLength&@CRLF&"$BaseStringLength="&$BaseStringLength&@CRLF&"$TotalRandomRowsINT="&$TotalRandomRowsINT) $s_Prepare=$s_Prepare1&$s_Prepare2& " LIMIT " & $MaxStringLength& " OFFSET " & $BaseStringLength&";" If FileExists($SQLiteEXEScrDir) and $msg = $Export_exe Then $sInput = ".mode tabs" & @CRLF $sInput &= $s_Prepare & @CRLF _SQLite_SQLiteExe($sDb, $sInput, $sOutput) FileWriteLine($f,$sOutput) ConsoleWrite('@@ Debug(193) : ' & "_SQLite_SQLiteExe" & "=" & Round(TimerDiff($nTimerQuery), 2) & " MSEC." & @LF & '>Error code: ' & @error & @LF) ;### Debug Console Else _SQLite_GetTextRowsOld(-1, $s_Prepare, $aResultRow, $iRows, $iColumns, $sErrorMsg, 64, False) ConsoleWrite('@@ Debug(193) : ' & "_SQLite_GetTextOLDRows" & "=" & Round(TimerDiff($nTimerQuery), 2) & " MSEC." & @LF & '>Error code: ' & @error & @LF) ;### Debug Console EndIf EndIf Next FileClose($f)Best, Randall ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW
piccaso Posted December 18, 2005 Posted December 18, 2005 (edited) @randallc use sqlite.exe's inbuilt functions, they dont have memory problems #include <sqlite.au3> Local $sInp, $sOut $sInp = ".mode tabs" & @CRLF $sInp &= ".output 'out.cvs'" & @CRLF; The output File $sInp &= "SELECT * FROM Orders;" & @CRLF; .dump always exports sql so we use select... _SQLite_SQLiteExe("..\2Nwind.db",$sInp,$sOut)exported 460800 rows x 14 Cols in about 11 seconds... Edited December 18, 2005 by piccaso CoProc Multi Process Helper libraryTrashBin.nfshost.com store your AutoIt related files here!AutoIt User Map
ptrex Posted December 18, 2005 Author Posted December 18, 2005 @randallcNo major development has been done so far, working on other projects as well. But during Xmas Holidays me I hope to have some time available.@WalkaboutRecordlocking is not supported as you can read on the website of SQLite. But this was not a problem, since SQLite and AutoIT are light products, with limited functionality compaired to other products. This is just the beauty of it all. Small but beautifull.Taking a look a Firebird might be interesting though.@PicassoSee Also here for FirebirdDB !! http://www.firebirdsql.org/For distributing FB you need :1 DLL (fbclient.dll) and 2 supporting files firebird.conf and firebird.msg and of course the database itself. Redistribution is simple, files just need to be copied. Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New
randallc Posted December 18, 2005 Posted December 18, 2005 (edited) @piccaso, Thanks for your help... but I still have a problem. if you can run the attached script, Listview sort column "e" (floating) (db col d), you will find the 500000 rows and above (100000) really takes 15-30 minutes. I presume it has something to do with memory, machine speed, or something to do with the difficult sort (if sorted on listview column "b", my same machine tales 25seconds! - which is probably comparable to your 11secs on simple data with no sort??). Let me know if you can do anything further; I cannot seem to make any difference to this by segmenting the output [which does help with your Table output]; I presume because the sort still has to occur on the total data. Best, Randall Edited December 19, 2005 by randallc ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW
piccaso Posted December 18, 2005 Posted December 18, 2005 @randallc if you use 'ORDER BY' in my last posted example it takes 50 seconds. if there is a index it takes about 16 seconds. i'll take a look at your script... @ptrex I know, but i cant find an api reference... CoProc Multi Process Helper libraryTrashBin.nfshost.com store your AutoIt related files here!AutoIt User Map
randallc Posted December 18, 2005 Posted December 18, 2005 (edited) Hi,yes, I forgot to ask; i have struggled to get the index lines made for the other columns at creation (presumably...?)I guess that is my problem; can you help with those lines?..._SQLite_QueryNoResult (-1, "CREATE TABLE "&$sDbTable&"( a INTEGER PRIMARY KEY, b TEXT, c INTEGER, d FLOAT );") _SQLite_QueryNoResult (-1, "CREATE INDEX b ON "&$sDbTable&"(b ASC);")That should fix my problem, if I canmake it work! I would think... If I just add more index lines, I don't get a table to sort using the previous commands!eg$s_Prepare = SELECT a , b, c , d FROM test ORDER BY a DESC, b ASC LIMIT 30;no longer works; should it be "ORDER BY INDEX e DESC" if I have created such an index??Thanks if you can explain it..randall Edited December 18, 2005 by randallc ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW
Mason Posted December 18, 2005 Posted December 18, 2005 I could be missing something, but is it possible to connect to other databases via network. For example, you have a hostname, database name, password, etc and you can manipulate that database rather than a local database in the examples. If it is not possible now, will it ever?
piccaso Posted December 18, 2005 Posted December 18, 2005 @randallc try_SQLite_QueryNoResult (-1, "CREATE INDEX idxB ON " & $sDbTable & " ( b );")or_SQLite_QueryNoResult (-1, "CREATE INDEX idxB ON COLLATE " & $sDbTable & " ASC ( b );")its just a syntax error. check out _SQLite_ErrMsg(). Select Statement doesent change. @Mason there is a payed version of sqlite that can do such things the free version we are using here isnt able to do so. CoProc Multi Process Helper libraryTrashBin.nfshost.com store your AutoIt related files here!AutoIt User Map
randallc Posted December 19, 2005 Posted December 19, 2005 (edited) Thanks, But I get "not an error" for this; _SQLite_QueryNoResult (-1, "CREATE INDEX b ON "&$sDbTable&"(b ASC);") MsgBox(0,"",_SQLite_ErrMsg())and your table function works on the Select after _SQLite_QueryNoResult (-1, "CREATE INDEX idxB ON " & $sDbTable & " ( b );")and $s_Prepare1 = "SELECT a,b,c,d FROM "&$sDbTable $s_Prepare2 = " ORDER BY " & $s_OrderColumn & " " & $s_SortOrder & ", b ASC" $s_Prepare=$s_Prepare1&$s_Prepare2&";", but _SQLite_SQLIteExe returns a blank Answer text file.. I'm going to take a while to learn all this, I fear! Best, randall [EDIT - PS I got it to work in the end; thanks; great for listview, and very fast for output (500000 in 9secs vs 5 mins best before!; I needed to include all columns except "primary integer key" in their individual indexes )] (PS in example, cancel dialog to go to create random for this example script) Edited December 19, 2005 by randallc ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW
jpm Posted December 20, 2005 Posted December 20, 2005 @petrex/@picasso Just checking the latest sqlite.zip I notice a still missing return0 in totalchanges after seterror(1) Continue the good work
piccaso Posted December 20, 2005 Posted December 20, 2005 now i get it!the Return Statement was missing completely Fixed that...SQLite.zipThank you jpm :"> CoProc Multi Process Helper libraryTrashBin.nfshost.com store your AutoIt related files here!AutoIt User Map
randallc Posted December 21, 2005 Posted December 21, 2005 (edited) hi, I'm trying to import csv; can anyone fix this code to work please? FileDelete("test.db") Local $sInput, $sOutput, $iRval ;$sInput = "create temporary table table1 (a,b,c); " & @CRLF $sInput = "CREATE temporary TABLE table1 (a,b,c,d);" & @CRLF $sInput &= ".separator tabs;" & @CRLF $sInput &= ".import table2.csv table1;" & @CRLF $sInput &= "CREATE TABLE table2 (keyfield INTEGER PRIMARY KEY, a,b,c,d);" & @CRLF $sInput &= ".mode insert table2" & @CRLF $sInput &= "begin; " & @CRLF $sInput &= "SELECT null, * FROM table1;" & @CRLF $sInput &= "commit;" & @CRLF _SQLite_SQLiteExe("test.db", $sInput, $sOutput)Thanks, Randall [EDIT - btw, attached update to where I have gone...] Edited December 21, 2005 by randallc ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW
piccaso Posted December 21, 2005 Posted December 21, 2005 '.import' always crashes (my) sqlite3.exe and i dont know why (jet)... CoProc Multi Process Helper libraryTrashBin.nfshost.com store your AutoIt related files here!AutoIt User Map
randallc Posted December 22, 2005 Posted December 22, 2005 Hi, Since my PM I have got "import" to work at the command line; just having trouble calling it. Best, Randall ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW
randallc Posted December 22, 2005 Posted December 22, 2005 OK, got one way; [for a csv with commas , 5 columns; no other testing] ;SQimportCsv.au3 #include <SQLite.au3> #include <Array.au3> $sDbTable="test" global $Dbfile="test.db" $DumpFile="table.txt" $CSVFile="Input.csv" $Success=FileDelete(@ScriptDir&"\"&$Dbfile) if not $Success then MsgBox(0,"","not $Success") Local $sInput, $sOutput, $iRval $sInput = "CREATE TABLE temptable(a,b,c,d,e);" & @CRLF MsgBox(0,"",'$sInput1 = ' & $sInput) _SQLite_SQLiteExe($Dbfile, $sInput, $sOutput) $sInput = '-separator , ' & $Dbfile& ' "'&".import "&$CSVFile&" temptable"&'"' & @CRLF ConsoleWrite('$sInput2 = ' & $sInput) MsgBox(0,"",'$sInput2 = ' & $sInput) $SQLiteCommand="sqlite3.exe " & $sInput $Command=@ComSpec & " /c "&$SQLiteCommand RunWait($Command,@WorkingDir,@SW_HIDE)Best, randall ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW
piccaso Posted December 22, 2005 Posted December 22, 2005 Added 'example_TsvImport.au3', Demonstrates Tab Seperated values ImportUpdated bundled SQLite Version to 3.2.8 (Changelog)SQLite.zipBeware: SQLite3.exe crashes if you try to '.import' into a Table that does not exist... CoProc Multi Process Helper libraryTrashBin.nfshost.com store your AutoIt related files here!AutoIt User Map
Recommended Posts