1
0

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:
madmaxoft@gmail.com
2013-04-07 19:28:32 +00:00
parent 92e782068f
commit 499962029a
10 changed files with 147613 additions and 4 deletions

View File

@@ -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