lxp vs sqlite for structured, but fast database-like format?
#1
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.
Reply
Thanks given by:
#2
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 Smile

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/blo...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/b...SQLite.lua
Reply
Thanks given by: DiamondToaster
#3
Thanks, I'll take a look at those. Smile
Reply
Thanks given by:
#4
Here is another example for a sqlite class: https://github.com/NiLSPACE/Login/blob/m...andler.lua
Reply
Thanks given by: DiamondToaster
#5
STR, that one is a bit too verbose for my likes Smile
Reply
Thanks given by:
#6
I really like it, because I don't have to create any query's. It's all handled in the class itself.
Reply
Thanks given by:




Users browsing this thread: 4 Guest(s)