Core icon indicating copy to clipboard operation
Core copied to clipboard

[feature] luasql support - mysql storage of user data

Open feardevilz opened this issue 9 years ago • 9 comments

Hi, I'm looking to see if you can add luasql storage support with mysql so core sqlite data can be stored into mysql for things such as bans, ranks and whitelist. The ranks functions are important as I use PermissionsEX now on other servers. It would be nice if ranks could follow the same sql format as its counter part in bucket.

PEX look-a-like: https://www.spigotmc.org/resources/powerfulperms-20-off.8143/

feardevilz avatar Sep 09 '16 08:09 feardevilz

Since Cuberite is compatible with LuaRocks, you can actually use any locally installed LuaRocks library, such as luasql, in your plugins. However, that makes the plugin dependent on that library and you should at least provide basic error-checking whether the library is available, and instructions for users on how to make it work on their platform.

Of course it would be nicer to have some SQL API it built-in directly in Cuberite, but that is somewhat unlikely in the nearest future.

madmaxoft avatar Sep 09 '16 08:09 madmaxoft

As long as the Windows version uses its own compiled version of Lua we can't really use LuaRocks.

NiLSPACE avatar Sep 09 '16 11:09 NiLSPACE

What? I've been using LuaRocks on windows for ages.

madmaxoft avatar Sep 09 '16 12:09 madmaxoft

After all, LuaRocks is the reason we have two Lua DLLs on windows - the real one and the proxy one.

madmaxoft avatar Sep 09 '16 12:09 madmaxoft

Oh, I didn't know that. I did try to use libraries from my Lua path, but it didn't work. I'll try again later today/tomorrow as it was a long time ago since I tried that.

NiLSPACE avatar Sep 09 '16 14:09 NiLSPACE

I've tried it, but I get this error:

[14:27:21] Line :1: module 'zip' not found:-58:\Projects\cuberite 2016-08-23\Server\lua\zip.lua'
no file 'D:-58:\Projects\cuberite 2016-08-23\Server\zip.lua'
no file 'D:-58:\Program Files (x86)\Lua\5.1\lua\zip.luac'
no file 'Plugins/Executor/zip.lua'
no file '.\zip.dll'
no file 'D:-58:\Projects\cuberite 2016-08-23\Server\loadall.dll'
no file 'Plugins/Executor\zip.dll'

Even though it works fine in the standalone version of Lua.

NiLSPACE avatar Sep 10 '16 12:09 NiLSPACE

That would be because Cuberite doesn't use the LUA_PATH and LUA_CPATH environment variables, so it doesn't have the LuaRocks path set properly. Just to test it out, try adding the path manually to package.path and package.cpath Lua globals before requiring the module.

madmaxoft avatar Sep 10 '16 23:09 madmaxoft

Yes, after that it works. Is there a way to change the path and cpath automatically? Otherwise we'd first have to check if the operation system is Linux or Windows before adding the paths.

NiLSPACE avatar Sep 11 '16 11:09 NiLSPACE

Thumbs up. A centralized SQL API could provide be very useful. Maybe in a such way one can switch between sqlite, mysql (cassandra? nosql?) and other db drivers without the plugins even knowing.

Basically, the plugin could choose between flatfile storage (already implemented) and the centralized SQL API cuberite could provide. The user would then setup the storage driver on cuberite itself, allowing the plugins to transparently use any storage driver and server the user so chooses.

This could end up being more complex than it needs to, but I think a centralized storage solution with swappable storage drivers would be the best solution for plugin developers and users.

yangm97 avatar Nov 07 '16 13:11 yangm97