dB help

Post Reply
Drevarr
Posts: 43
Joined: Tue Aug 06, 2013 12:07 am
Location: GA, USA

dB help

Post by Drevarr »

I converted my equipment spreadsheet to a database and managed to get the item stats echoed where i wanted them, but I need to update the data for a new value. I added iLVL to the create and can fetch and add the value but can't UPDATE the dB using the Wiki Example

Code: Select all

-- Initialize the duris database
db:create("duris", {stats={"ID", "Vnum", "TYPE", "SLOT", "NAME", "LOCATION", "STATS", "iLVL"}})
I'm completing a fetch using the NAME and LOCATION which is working:

Code: Select all

local mydb = db:get_database("duris")
local res = db:fetch(mydb.stats,{db:eq(mydb.stats.LOCATION, zoneName), db:like(mydb.stats.NAME, itemName)})
display(res)

Outputs:
{
  {
    TYPE = "INSTRUMENT",
    Vnum = "29480.00",
    SLOT = "Attach",
    ID = "3336",
    NAME = "the horn of the dragonslayer",
    LOCATION = "Harrow -The Gnome Village",
    STATS = ""
  }
}
It would appear I am updating the iLVL appropriately:

Code: Select all

res[1].iLVL = itemValue
cecho("<DodgerBlue>  Item Value set to: <khaki>" ..itemValue)
display(res)

Outputs:
Item Value set to: 1
{
  {
    iLVL = 1,
    LOCATION = "Harrow -The Gnome Village",
    NAME = "the horn of the dragonslayer",
    SLOT = "Attach",
    ID = "3336",
    TYPE = "INSTRUMENT",
    Vnum = "29480.00",
    STATS = ""
  }
}
However I can't manage to commit the update to the dB. What am i missing?

Code: Select all

db:update(mydb.stats, res[1])

Outputs:
[ERROR:] object:<testvalue> function:<Trigger78>
         <[string "-------------------------------------------..."]:1118: Can only update a table 
with a _row_id>

User avatar
Vadi
Posts: 5042
Joined: Sat Mar 14, 2009 3:13 pm

Re: dB help

Post by Vadi »

Haven't got time to run your examples and find the problem thoroughly, but have you updated your DB.lua? see http://forums.mudlet.org/viewtopic.php? ... 270#p19825. If you haven't, follow those steps and re-do your database if it still doesn't work.

User avatar
Vadi
Posts: 5042
Joined: Sat Mar 14, 2009 3:13 pm

Re: dB help

Post by Vadi »

Have you got it working?

Drevarr
Posts: 43
Joined: Tue Aug 06, 2013 12:07 am
Location: GA, USA

Re: dB help

Post by Drevarr »

I did manage to get it working. I updated my db.lua script just in case it had changed since the last time and started from a clean db that included the new field with a default value and imported the 13k entries through db sorcerer.

I think i had fubared the db row_id when i was in db sorc on the previous attempts. I could query data but not write data. Under the last attempt it is working as expected.

Post Reply