My apologies for hijacking the thread.ixokai wrote:First, can this thread *not* be a generic place where all questions related to the db frontend go? Its extremely hard to follow entirely separate conversations in a multi-page thread, especially when said conversations don't relate directly to the original topic(luasql, as opposed to the db frontend)
One thread per issue is preferred, imho
First, display the full current contents of this table with:
display(db:fetch(mydb.tablename))
And copy/paste it to us? I can't use real values of mydb or tablename because there's been too many comments with output but not code, and it scrolled off of the forums view.
There may be a problem with your db:create() call (the error related to 'field does not exist') and that may even be a bug -- or there may be that you're trying to add duplicate data. And if you do that with multiple items in a db:add(), the -whole- thing cancels out, not just the duplicate.
As to the possibility of the first problem, try changing the table definition from {"name"} to {name=""}
display( db:fetch( mydb.folks)) returns:
Tried changing the code, as per a suggestion above:
table {}
init --
[syntax="lua"]
echo( "Initializing.\n")
db:create("all_people", {all_folks={"all_names"}})
local mydb = db:get_database("all_people")
personTable = {{all_names="Abby"},{all_names="Bob"},{all_names="Carlos"}}
db:add(mydb.all_folks, personTable)
[/syntax]
find --
[syntax="lua"]
echo("Querying " .. matches[2] .. ".\n")
local mydb = db:get_database("all_people")
--local searching = capitalize(matches[2])
local results= db:fetch(mydb.all_folks, db:eq(mydb.all_folks.all_names, matches[2]))
display(results)
[/syntax]
display --
[syntax="lua"]
local mydb = db:get_database( "all_people")
display(db:fetch( mydb.all_folks))
[/syntax]
Debug output --
Code: Select all
Alias name=^init$(^init$) matched.
Alias: capture group #1 = <init>
LUA: ERROR running script ^init$ (Alias1) ERROR:C:/Users/emily/.config/mudlet/db.lua:517: Failed to
add item: this is probably a violation of a UNIQUE index or other constraint.Alias name=^find
(\w+)(^find (\w+)) matched.
Alias: capture group #1 = <find Abby>
Alias: capture group #2 = <Abby>
LUA: ERROR running script ^find (\w+) (Alias2) ERROR:C:/Users/emily/.config/mudlet/db.lua:1017:
Attempt to access field all_names in sheet all_folks in database allpeople that does not exist.
Alias name=^display$(^display$) matched.
Alias: capture group #1 = <display>
LUA OK script ^display$ (Alias3) ran without errors
Thank you for your continued help.