Added SQLite and LuaSQLite, Lua plugins can now use SQLite.
git-svn-id: http://mc-server.googlecode.com/svn/trunk@1368 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
@@ -54,6 +54,7 @@ function Initialize(Plugin)
|
||||
f:write(n, "\n");
|
||||
end
|
||||
f:close();
|
||||
LOG("API.txt written.");
|
||||
end
|
||||
|
||||
|
||||
@@ -136,6 +137,35 @@ function Initialize(Plugin)
|
||||
end
|
||||
|
||||
|
||||
-- Debug SQLite binding
|
||||
local TestDB, ErrCode, ErrMsg = sqlite3.open("test.sqlite");
|
||||
if (TestDB ~= nil) then
|
||||
local function ShowRow(UserData, NumCols, Values, Names)
|
||||
assert(UserData == 'UserData');
|
||||
LOG("New row");
|
||||
for i = 1, NumCols do
|
||||
LOG(" " .. Names[i] .. " = " .. Values[i]);
|
||||
end
|
||||
return 0;
|
||||
end
|
||||
local sql = [=[
|
||||
CREATE TABLE numbers(num1,num2,str);
|
||||
INSERT INTO numbers VALUES(1, 11, "ABC");
|
||||
INSERT INTO numbers VALUES(2, 22, "DEF");
|
||||
INSERT INTO numbers VALUES(3, 33, "UVW");
|
||||
INSERT INTO numbers VALUES(4, 44, "XYZ");
|
||||
SELECT * FROM numbers;
|
||||
]=]
|
||||
local Res = TestDB:exec(sql, ShowRow, 'UserData');
|
||||
if (Res ~= sqlite3.OK) then
|
||||
LOG("TestDB:exec() failed: " .. Res .. " (" .. TestDB:errmsg() .. ")");
|
||||
end;
|
||||
TestDB:close();
|
||||
else
|
||||
-- This happens if for example SQLite cannot open the file (eg. a folder with the same name exists)
|
||||
LOG("SQLite3 failed to open DB! (" .. ErrCode .. ", " .. ErrMsg ..")");
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user