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

User avatar
burli
Member
 
Posts: 1313
Joined: Fri Apr 10, 2015 13:18

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

by burli » Sat Jun 04, 2016 12:34

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?
 

vitalie
Member
 
Posts: 66
Joined: Wed Feb 24, 2016 07:38
GitHub: ciubotaru

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

by vitalie » Sat Jun 04, 2016 15:13

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).
 

User avatar
Krock
Member
 
Posts: 3598
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker

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

by Krock » Sat Jun 04, 2016 15:20

"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.
Newest Win32 builds - Find a mod - All my mods
ALL YOUR DONATION ARE BELONG TO PARAMAT (Please support him and Minetest)
New DuckDuckGo !bang: !mtmod <keyword here>
 

User avatar
burli
Member
 
Posts: 1313
Joined: Fri Apr 10, 2015 13:18

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

by burli » Sat Jun 04, 2016 16:07

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?
 

User avatar
Krock
Member
 
Posts: 3598
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker

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

by Krock » Sat Jun 04, 2016 16:14

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.
Newest Win32 builds - Find a mod - All my mods
ALL YOUR DONATION ARE BELONG TO PARAMAT (Please support him and Minetest)
New DuckDuckGo !bang: !mtmod <keyword here>
 

User avatar
burli
Member
 
Posts: 1313
Joined: Fri Apr 10, 2015 13:18

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

by burli » Sat Jun 04, 2016 16:17

Thx, I will try it
 

User avatar
burli
Member
 
Posts: 1313
Joined: Fri Apr 10, 2015 13:18

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

by burli » Sat Jun 04, 2016 16:21

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")
 


Return to Modding Discussion

Who is online

Users browsing this forum: No registered users and 4 guests

cron