lxp vs sqlite for structured, but fast database-like format? - Printable Version +- Cuberite Forum (https://forum.cuberite.org) +-- Forum: Plugins (https://forum.cuberite.org/forum-1.html) +--- Forum: Plugin Discussion (https://forum.cuberite.org/forum-8.html) +--- Thread: lxp vs sqlite for structured, but fast database-like format? (/thread-1874.html) |
lxp vs sqlite for structured, but fast database-like format? - DiamondToaster - 04-16-2015 So, what I'm attempting to do is implementing Factions through MCServer API. I would like some kind of structured data type, but also need it to be relatively fast. What this database will hold is: Faction Object: -Name: --"TestFaction" -Players: --"TestPlayer" --"OtherPlayer" -ClaimedChunks: --"5, 16" --"5, 17" -Power --"7" Something like that. It would need to hold hundreds of these faction "objects". I would very much appreciate the input of more experienced plugin developers, as I'm not very familiar with the lxp and SQLite classes. RE: lxp vs sqlite for structured, but fast database-like format? - xoft - 04-16-2015 If your structured data follows more or less the same structure for every object, then your best bet is definitely SQLite. Lxp can only parse XML files, but it cannot write them, so you'd need to write a serializer, and of course the actual storage (files / DB) for the data. Therefore I'd strongly recommend using SQLite, since it's easier Should you need an example, have a look at the Gallery plugin. It defines a Lua class that handles the SQLite-related tasks, hiding all the SQL details inside. https://github.com/mc-server/Gallery/blob/master/Storage_SQLite.lua The GalExport plugin goes even a bit further and shares the same database with the Gallery plugin, altering it for its own data. The approach is the same - create a class that hides the SQL ugliness behind nice function calls: https://github.com/madmaxoft/GalExport/blob/master/Storage_SQLite.lua RE: lxp vs sqlite for structured, but fast database-like format? - DiamondToaster - 04-16-2015 Thanks, I'll take a look at those. RE: lxp vs sqlite for structured, but fast database-like format? - NiLSPACE - 04-16-2015 Here is another example for a sqlite class: https://github.com/NiLSPACE/Login/blob/master/cSQLiteHandler.lua RE: lxp vs sqlite for structured, but fast database-like format? - xoft - 04-17-2015 STR, that one is a bit too verbose for my likes RE: lxp vs sqlite for structured, but fast database-like format? - NiLSPACE - 04-18-2015 I really like it, because I don't have to create any query's. It's all handled in the class itself. |