问题
I have a problem with SQLite v3.22.0 and AutoIt v3.3.14.3. Trying to create a database works but the table does not get created. I use the AutoIt example code:
#include <MsgBoxConstants.au3>
#include <SQLite.au3>
#include <SQLite.dll.au3>
Local $hQuery, $aRow, $sMsg
_SQLite_Startup()
ConsoleWrite("_SQLite_LibVersion=" & _SQLite_LibVersion() & @CRLF)
_SQLite_Open() ; open :memory: Database
_SQLite_Exec(-1, "CREATE TABLE aTest (a,b,c);") ; CREATE a Table
_SQLite_Exec(-1, "INSERT INTO aTest(a,b,c) VALUES ('c','2','World');") ; INSERT Data
_SQLite_Exec(-1, "INSERT INTO aTest(a,b,c) VALUES ('b','3',' ');") ; INSERT Data
_SQLite_Exec(-1, "INSERT INTO aTest(a,b,c) VALUES ('a','1','Hello');") ; INSERT Data
_SQLite_Query(-1, "SELECT c FROM aTest ORDER BY a;", $hQuery) ; the query
While _SQLite_FetchData($hQuery, $aRow) = $SQLITE_OK
$sMsg &= $aRow[0]
WEnd
_SQLite_Exec(-1, "DROP TABLE aTest;") ; Remove the table
MsgBox($MB_SYSTEMMODAL, "SQLite", "Get Data using a Query : " & $sMsg)
_SQLite_Close()
_SQLite_Shutdown()
; Output:
; Hello World
If I request the SQLite error, I get "Library used incorrectly". What's the problem in this case?
回答1:
Whats the problem in this case?
As per Documentation - Script breaking changes :
_SQLite_Startup()
function no longer automatically downloads the SQLite DLL files from autoitscript.com. Most users were completely unaware that this download was occuring on each script run and it was also a severe bandwidth hog for the website. The SQLite DLLs must now be manually download. See the _SQLite_Startup() documentation for details.
If _SQLite_Startup()
's first parameter is omitted, then dll file must reside in @SystemDir
, @WindowsDir
, @ScriptDir
or @WorkingDir
for this function to succeed.
- Download sqlite3.dll,
- remove
#include <SQLite.dll.au3>
, then - provide
_SQLite_Startup()
's first parameter with location of dll file (redundant if present in one of four previously mentioned locations).
Related.
回答2:
AutoIt v3.3.14.3 has a bug; install AutoIt v3.3.14.2 or get the bug-fix.
来源:https://stackoverflow.com/questions/48990852/unable-to-create-table-why-does-this-code-fail