luasql in mudlet

kkerwin1
Posts: 22
Joined: Tue Apr 20, 2010 7:37 am

Re: luasql in mudlet

Post by kkerwin1 »

tsuujin wrote:yeah, fetch_database is wrong, and should be corrected in the manual. Go back to get_database
Cool. fetch_database() changed to get_database() in both aliases. Debug output is now:

Code: Select all

Alias name=Init DB(^init$) matched.
Alias: capture group #1 = <init>
LUA: ERROR running script Init DB (Alias2) ERROR:/home/kris/.config/mudlet/db.lua:517: Failed to 
add item: this is probably a violation of a UNIQUE index or other constraint.Alias name=query 
db(^find (\w+)$) matched.
Alias: capture group #1 = <find Abby>
Alias: capture group #2 = <Abby>
LUA: ERROR running script query db (Alias3) ERROR:/home/kris/.config/mudlet/db.lua:1017: Attempt to 
access field name in sheet folks in database people that does not exist.

kkerwin1
Posts: 22
Joined: Tue Apr 20, 2010 7:37 am

Re: luasql in mudlet

Post by kkerwin1 »

kkerwin1 wrote:
tsuujin wrote:yeah, fetch_database is wrong, and should be corrected in the manual. Go back to get_database
Cool. fetch_database() changed to get_database() in both aliases. Debug output is now:

Code: Select all

Alias name=Init DB(^init$) matched.
Alias: capture group #1 = <init>
LUA: ERROR running script Init DB (Alias2) ERROR:/home/kris/.config/mudlet/db.lua:517: Failed to 
add item: this is probably a violation of a UNIQUE index or other constraint.Alias name=query 
db(^find (\w+)$) matched.
Alias: capture group #1 = <find Abby>
Alias: capture group #2 = <Abby>
LUA: ERROR running script query db (Alias3) ERROR:/home/kris/.config/mudlet/db.lua:1017: Attempt to 
access field name in sheet folks in database people that does not exist.
Ok. I want to call your attention to one line in the above debug output:

Code: Select all

LUA: ERROR running script query db (Alias3) ERROR:/home/kris/mudlet/db.lua:1017: Attempt to access field name in sheet folks in database people that does not exist.
I opened the database file using a database browser (I think sqlitebrowser). Anyway, it shows the database "people", the sheet "folks", but it does not show the field "name". None of the names are being written to the file because the field "name" does not exist.

I tried adding the field manually within sqlitebrowser, and then running the alias again. However, no data was written to the new field "name", as was demonstrated by the "find" alias, and then confirmed by another use of sqlitebrowser to inspect the contents of the database.

User avatar
tsuujin
Posts: 695
Joined: Fri Feb 26, 2010 12:59 am
Location: California
Contact:

Re: luasql in mudlet

Post by tsuujin »

Hmm, as far as I can tell, your db:add statement is clean. I'm not entirely certain why it doesn't work, honestly.

kaeus
Posts: 50
Joined: Thu Dec 31, 2009 4:33 pm

Re: luasql in mudlet

Post by kaeus »

Where is the db file located anyway?

User avatar
tsuujin
Posts: 695
Joined: Fri Feb 26, 2010 12:59 am
Location: California
Contact:

Re: luasql in mudlet

Post by tsuujin »

If he created it with the db wrapper, i think it puts it into your home directory.

kaeus
Posts: 50
Joined: Thu Dec 31, 2009 4:33 pm

Re: luasql in mudlet

Post by kaeus »

tsuujin wrote:If he created it with the db wrapper, i think it puts it into your home directory.
Where would that equate to on a Windows system?

User avatar
tsuujin
Posts: 695
Joined: Fri Feb 26, 2010 12:59 am
Location: California
Contact:

Re: luasql in mudlet

Post by tsuujin »

drop
[syntax=lua]echo(getMudletHomeDir())[/syntax]
into a script and execute, to show you where that is.

kkerwin1
Posts: 22
Joined: Tue Apr 20, 2010 7:37 am

Re: luasql in mudlet

Post by kkerwin1 »

Tried the above on a separate Windows Vista computer. Same problem. The db:add() simply doesn't want to do its job.

User avatar
tsuujin
Posts: 695
Joined: Fri Feb 26, 2010 12:59 am
Location: California
Contact:

Re: luasql in mudlet

Post by tsuujin »

kkerwin1 wrote:Tried the above on a separate Windows Vista computer. Same problem. The db:add() simply doesn't want to do its job.
It keeps throwing out an error about being unable to add, but doesn't give an actual reason other than suggesting you might have a constraint, but I've seen your DB constructor and didn't see any constraints.

Do me a favor, change the database and table name in all of your scripts and try again from scratch.

ixokai
Posts: 63
Joined: Fri Dec 25, 2009 7:43 am

Re: luasql in mudlet

Post by ixokai »

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=""}

Post Reply