From 499962029a94074ecd007a1be5f760337ff9ffbb Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Sun, 7 Apr 2013 19:28:32 +0000 Subject: 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 --- MCServer/Plugins/Debuggers/Debuggers.lua | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'MCServer/Plugins/Debuggers/Debuggers.lua') diff --git a/MCServer/Plugins/Debuggers/Debuggers.lua b/MCServer/Plugins/Debuggers/Debuggers.lua index d3d70b98c..c1c0e1fe6 100644 --- a/MCServer/Plugins/Debuggers/Debuggers.lua +++ b/MCServer/Plugins/Debuggers/Debuggers.lua @@ -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 -- cgit v1.2.3