Play around luasql and servman on DCSW 1.2.6 years ago, and build an running statistics system
It seems that your require("luasql") failed,
check package.path and package.cpath and luasql staffs in proper directory
My code:
-- all db operations(create/update/delete/insert) goes into db_ops.lua
log("load db_ops.lua ...")
package.path = package.cpath..";.\\Scripts\\Luasql\\?.lua;"
package.cpath = package.cpath..";.\\Scripts\\\\?.dll;"
mysqlenv = nil
mysqlcon = nil
db_initOK = false
luasql = nil
luasql = require "luasql.mysql"
if luasql == nil then
log('luasql loaded NULL!')
else
dofile(rootpath ..'/db_ops.lua')
end
-- in db_ops.lua
function db_Open()
if ( luasql == nil ) then return end
mysqlenv = luasql:mysql()
if ( mysqlenv ~= nil ) then
-- 数据库名称, 用户名, 密码, 数据库服务器IP [,数据库端口]
mysqlcon = mysqlenv:connect("db_DCSW","db_user","xxxxxx","nnn.nnn.nnn.nnn", nnnn)
if ( mysqlcon == nil ) then
mysqlenv:close()
else
db_initOK = true
end
end
end