[lua]database = getDatabase();[/lua] will create a database within your script folder called scriptDatabase.
This is an example of how to create tables:
[lua]database:queryupdate("CREATE TABLE IF NOT EXISTS 'areas' ('ID' INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL , 'name' VARCHAR, 'startChunkpositionX' INTEGER, 'startChunkpositionY' INTEGER, 'startChunkpositionZ' INTEGER, 'startBlockpositionX' INTEGER, 'startBlockpositionY' INTEGER, 'startBlockpositionZ' INTEGER,'endChunkpositionX' INTEGER, 'endChunkpositionY' INTEGER, 'endChunkpositionZ' INTEGER, 'endBlockpositionX' INTEGER, 'endBlockpositionY' INTEGER, 'endBlockpositionZ' INTEGER, 'playerID' INTEGER);");[/lua]
This is an example of how to query the database:
[lua] result = database:query("SELECT * FROM areas;");
while result:next() do
local area = {};
area["areaID"] = result:getInt("ID");
area["playerID"] = result:getInt("playerID");
area["areaName"] = result:getString("name");
area["startChunkpositionX"] = result:getInt("startChunkpositionX");
area["startChunkpositionY"] = result:getInt("startChunkpositionY");
area["startChunkpositionZ"] = result:getInt("startChunkpositionZ");
area["startBlockpositionX"] = result:getInt("startBlockpositionX");
area["startBlockpositionY"] = result:getInt("startBlockpositionY");
area["startBlockpositionZ"] = result:getInt("startBlockpositionZ");
area["endChunkpositionX"] = result:getInt("endChunkpositionX");
area["endChunkpositionY"] = result:getInt("endChunkpositionY");
area["endChunkpositionZ"] = result:getInt("endChunkpositionZ");
area["endBlockpositionX"] = result:getInt("endBlockpositionX");
area["endBlockpositionY"] = result:getInt("endBlockpositionY");
area["endBlockpositionZ"] = result:getInt("endBlockpositionZ");
area["rights"] = {};
calculateGlobalAreaPosition(area);
areas[result:getInt("ID")] = area;
end[/lua]
This all comes from the AreaProtection script provided by the devs.