[SOLVED] Sqlite3 Rows
#11
Your code is a total unreadable mess.

But the main issue I see is that you're opening a DB file and trying to read data from it, although you have no guarantee that the DB file even has the table you're reading. And it doesn't. When you open a file without any path, you're opening it in "current folder", which normally is right next to the Cuberite executable. The sqlite3 file that you have in your plugin folder doesn't get touched at all.

For testing purposes, you can manually fill the DB file next to the Cuberite executable with data. But for a well-behaved plugin, your code should, in its final version, check the file and do any adjustments (create tables, add missing columns) that it needs before further using that file.
Reply
Thanks given by:
#12
(11-05-2016, 09:11 PM)xoft Wrote: Your code is a total unreadable mess.

But the main issue I see is that you're opening a DB file and trying to read data from it, although you have no guarantee that the DB file even has the table you're reading. And it doesn't. When you open a file without any path, you're opening it in "current folder", which normally is right next to the Cuberite executable. The sqlite3 file that you have in your plugin folder doesn't get touched at all.

For testing purposes, you can manually fill the DB file next to the Cuberite executable with data. But for a well-behaved plugin, your code should, in its final version, check the file and do any adjustments (create tables, add missing columns) that it needs before further using that file.
Note: I just started learning lua and the cuberite api

anyway i fixed the problem.
Reply
Thanks given by:
#13
@xoft again, "next to the cuberite binary" isn't the whole truth.

Current folder means from where you execute stuff, which should he the Server directory but doesn't have to be.

Anyway, shouldn't be "current directory" for a plugin its own directory? I would expect that cuberite is simulating that
Reply
Thanks given by:
#14
(11-06-2016, 08:46 AM)Cl1608Ho Wrote: @xoft again, "next to the cuberite binary" isn't the whole truth.

Current folder means from where you execute stuff, which should he the Server directory but doesn't have to be.

Anyway, shouldn't be "current directory" for a plugin its own directory? I would expect that cuberite is simulating that
Yup, i've changed my code a little bit to make load the sqlite3 from the plugin's folder
<shcode=lua>
db = sqlite3.open('Plugins/EggWars/storage.sqlite3')
</shcode>
again the default directory is the main cuberite directory.
Reply
Thanks given by:
#15
Don't hard-code plugin path (server admin may change the folder name to anything), and don't put data-files next to plugin program files (It is possible Cuberite will disable writing to that folder in the future, to further protect the plugins - just like Windows protects its Program Files folder).
Reply
Thanks given by:
#16
If you want one strong argument why not put data files next to plugin code files, consider updates. The server admin wants to update the plugin by deleting its folder contents and unpacking a new ZIP into the empty folder. They don't want to comb through the files, deciding which ones to keep.
Reply
Thanks given by:
#17
Where else would you put a plugin's database file then? Should we put them in the Cuberite root? I think it becomes quite messy then...
Reply
Thanks given by:
#18
I'd love to have specific folders where we can put all our databases and configuration files like @xoft proposed here
Reply
Thanks given by:
#19
if it's in Cuberite root folder it would look very messy.
anything related to the plugin should be in the plugin's folder.
Reply
Thanks given by:




Users browsing this thread: 1 Guest(s)