[SOLVED] Sqlite3 Rows
#1
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
Reply
Thanks given by:
#2
Just like any SQL engine you have to create the tables first: https://github.com/cuberite/WorldEdit/bl...ipts/1.sql
Reply
Thanks given by:
#3
(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.
Reply
Thanks given by:
#4
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
Reply
Thanks given by:
#5
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.
Reply
Thanks given by:
#6
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
Reply
Thanks given by:
#7
[09:32:47] Can't load plugin TestPlugin because of an initialization error in file Plugins/TestPlugin/test.lua: 2 (no such table: test)
@xoft ft tried it didn't work
Reply
Thanks given by:
#8
Then you'll have to post your entire code for the Initialize function and the database you're using.
Reply
Thanks given by:
#9
i've sent you a pm
Reply
Thanks given by:
#10
I've tried to change the name (in-order to make a new sqlite3 file) it failed.

Any ideas?
Reply
Thanks given by:




Users browsing this thread: 8 Guest(s)