Page 1 of 1

How can I store and search a large tabel from a mod?

PostPosted: Sat Jun 04, 2016 12:34
by burli
I want to be able to store and search a larger amount of data on disc. Sadly there is still no database API to the default database.

Is there any efficient way for a lua mod to store and search a large tabel on disc? The only thing I found that might work because it is pure lua is this http://scilua.org/ljsqlite3.html. Just requires the LuaJIT (and clib_sqlite3, damn)

I don't want to store and parse JSON to a plain text file

Any suggestions?

Re: How can I store and search a large tabel from a mod?

PostPosted: Sat Jun 04, 2016 15:13
by vitalie
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
$ sudo luarocks install lsqlite


Then add "require(sqlite3)" to your lua file and work with the db transparently (send queries, get results and use them in mod).

Re: How can I store and search a large tabel from a mod?

PostPosted: Sat Jun 04, 2016 15:20
by Krock
"the default database"
I think you mean map.sqlite here. There are already enough read/write actions performed when you play Minetest. So using a new database is the best way to save and manage the data. lsqlite3 might not be the fastest way to do this but it works well.

Re: How can I store and search a large tabel from a mod?

PostPosted: Sat Jun 04, 2016 16:07
by burli
vitalie wrote:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
$ sudo luarocks install lsqlite


Then add "require(sqlite3)" to your lua file and work with the db transparently (send queries, get results and use them in mod).

Does this work for Windows and OS X too?

Re: How can I store and search a large tabel from a mod?

PostPosted: Sat Jun 04, 2016 16:14
by Krock
burli wrote:Does this work for Windows and OS X too?

Works fine on Windows (using the compiled lsqlite.dll in the same directory). Not sure about OS X but it should work there too.

Re: How can I store and search a large tabel from a mod?

PostPosted: Sat Jun 04, 2016 16:17
by burli
Thx, I will try it

Re: How can I store and search a large tabel from a mod?

PostPosted: Sat Jun 04, 2016 16:21
by burli
This is correct

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
$ sudo luarocks install lsqlite3


Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
require("lsqlite3")