-- LuaDirector MySQL demo
mysql = require "luasql.mysql"
----------------------------------------
-- Returns either the query result as list of propLists,
-- or an error string
----------------------------------------
on.mysql_query = function (sql)
local env = mysql.mysql()
local conn,err = env:connect('LuaDirectorTest', 'root', '<password>')
if err~=nil then
env:close()
return err
end
local cursor,err = conn:execute(sql)
if err~=nil then
conn:close()
env:close()
return err
else
local res = {}
local row = cursor:fetch ({}, "a")
while row~=nil do
res[#res+1] = row
row = cursor:fetch ({}, "a")
end
cursor:close()
conn:close()
env:close()
return res
end
end