Cuberite Forum

Full Version: [SOLVED] Sqlite3 Rows
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I'm making a plugin and need to store some data.

I'm using sqlite3 and everytime i run my cuberite server i see this error.

[10:45:24] Can't load plugin TestPlugin because of an initialization error in file Plugins/TestPlugin/test.lua: 2 (no such table: table)

Here's my code

db = sqlite3.open('test.sqlite3')
LOG(db.rows('SELECT * FROM table'))
db:close()


EDIT:
i just realised that i'm an idiot the db files were located in cuberite's folder not in the plugin's folder
Just like any SQL engine you have to create the tables first: https://github.com/cuberite/WorldEdit/bl...ipts/1.sql
(11-03-2016, 01:56 AM)NiLSPACE Wrote: [ -> ]Just like any SQL engine you have to create the tables first: https://github.com/cuberite/WorldEdit/bl...ipts/1.sql
i undestand how sql works i have already created the table and add a couple of rows.
You can take a look at the Gallery plugin. It has an ExecuteStatement method which you give the SQL statement, optional parameters and optional callback: https://github.com/cuberite/gallery/blob...a#L83-L108
Then you can use it like this: https://github.com/cuberite/gallery/blob...#L237-L249
First, you should be calling methods on the "db" object with a colon: db:rows(...)
Second, db:rows(...) creates an iterator, the LOG function cannot output the value of an iterator.
If you want to output the values in all rows, you can do this:
for a in db:rows('SELECT * FROM table') do
  for k, v in pairs(a) do
    LOG(k .. " = " .. v)
  end
end
[09:32:47] Can't load plugin TestPlugin because of an initialization error in file Plugins/TestPlugin/test.lua: 2 (no such table: test)
 ft tried it didn't work
Then you'll have to post your entire code for the Initialize function and the database you're using.
i've sent you a pm
I've tried to change the name (in-order to make a new sqlite3 file) it failed.

Any ideas?
Pages: 1 2