As an addon it would be difficult, not sure if it's actually possible.
With ArcEmu:
LuaHypArc:
WorldDBQuery("Your Query Here")
CharDBQuery("Your Query Here")
GetColumn
GetColumnCount
GetRowCount
NextRow
Example code snippet:
Code:
local item = WorldDBQuery("SELECT `quality` FROM `items` WHERE `entry` = '"..code.."';")
if item ~= nil then -- Check it exists
item = item:GetColumn(0):GetString()
if item == 2 then -- if it's got a quality of 2
player:AddItem(code, 1)
end
end
LuaBridge:
These are executed on WorldDB or CharacterDB. Both of these are global variables.
:Query()
:Execute()