Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loading third-party library mysql failed #107

Open
xeweicheng opened this issue Jul 14, 2020 · 0 comments
Open

Loading third-party library mysql failed #107

xeweicheng opened this issue Jul 14, 2020 · 0 comments

Comments

@xeweicheng
Copy link

luasql = require "luasql.mysql"

--创建环境对象
env = luasql.mysql()

--连接数据库
conn = env:connect("waterlot","root","ctu96jsj","127.0.0.1",3306)

--设置数据库的编码格式
conn:execute"SET NAMES UTF8"

--执行数据库操作
cur = conn:execute("select * from hts_company")

row = cur:fetch({},"a")

--文件对象的创建
file = io.open("hts_company.txt","w+");

while row do
var = string.format("%d %s\n", row.id, row.name)

print(var)

file:write(var)

row = cur:fetch(row,"a")

end

file:close() --关闭文件对象
conn:close() --关闭数据库连接
env:close() --关闭数据库环境

2020-07-14 14:31:02.319 [error] Lua Hook: Failed to load lua script "/var/lib/emqx/scripts/test_mysql.lua" due to error {{lua_error,
{no_module,
<<"luasql.mysql">>,
<<"'./luasql/mysql.lua' './luasql/mysql/init.lua' ">>},
{luerl,
{array,
13,
100,
undefined,
{{{table,
{array,
0,
10,
nil,
10},
{{{{empty,
<<"_G">>,
{tref,
0},
empty,
<<"_VERSION">>,
<<"Lua 5.2">>,
empty},
<<"assert">>,
{function,
#Fun<luerl_lib_basic.0.131962688>},
{empty,
<<"bit32">>,
{tref,
5},
empty},
<<"collectgarbage">>,
{function,
#Fun<luerl_lib_basic.1.131962688>},
{empty,
<<"debug">>

Remark: other self .lua aslo not load by require, sample require("NumConvert")

2020-07-14 14:31:02.316 [error] Lua Hook: Failed to load lua script "/var/lib/emqx/scripts/mcu_api.lua" due to error {{lua_error,
{no_module,
<<"NumConvert">>,
<<"'./NumConvert.lua' './NumConvert/init.lua' ">>},
{luerl,
{array,
13,
100,
undefined,
{{{table,
{array,
0,
10,
nil,
10},

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant