Cuberite Forum
[SOLVED] Sqlite3 Rows - Printable Version

+- Cuberite Forum (https://forum.cuberite.org)
+-- Forum: Plugins (https://forum.cuberite.org/forum-1.html)
+--- Forum: Plugin Discussion (https://forum.cuberite.org/forum-8.html)
+--- Thread: [SOLVED] Sqlite3 Rows (/thread-2574.html)

Pages: 1 2


RE: [SOLVED] Sqlite3 Rows - xoft - 11-05-2016

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.


RE: [SOLVED] Sqlite3 Rows - denwo - 11-06-2016

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


RE: [SOLVED] Sqlite3 Rows - ShadowCone - 11-06-2016

@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


RE: [SOLVED] Sqlite3 Rows - denwo - 11-07-2016

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


RE: [SOLVED] Sqlite3 Rows - xoft - 11-08-2016

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


RE: [SOLVED] Sqlite3 Rows - xoft - 11-08-2016

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.


RE: [SOLVED] Sqlite3 Rows - PureTryOut - 11-08-2016

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


RE: [SOLVED] Sqlite3 Rows - NiLSPACE - 11-08-2016

I'd love to have specific folders where we can put all our databases and configuration files like @xoft proposed here


RE: [SOLVED] Sqlite3 Rows - denwo - 11-09-2016

if it's in Cuberite root folder it would look very messy.
anything related to the plugin should be in the plugin's folder.