<div dir="ltr"><div>I'm wriiting because I can't seem to get Lua from within Freeswitch to load the luasql mysql object. The error on the freeswitch console states that there's a error loading module luasql.mysql' but when i run a script from the shell requiring the same file it works just fine. I did due diligience and researched the issue and seen someone state the proble is due to lua being compiled from C++ code and the mysql module being compiled from C source code. Any help will be greatly appreciated because none of my scripts work because they are all database driven.</div>
<div><br></div><div>FS Cli error:</div><div>#########################</div><div><div>2014-01-09 05:36:31.432815 [ERR] mod_lua.cpp:199 error loading module 'luasql.mysql' from file '/usr/local/lib/lua/5.2/luasql/mysql.so':</div>
<div> /usr/local/lib/lua/5.2/luasql/mysql.so: undefined symbol: lua_getfield</div><div>stack traceback:</div><div> [C]: in ?</div><div> [C]: in function 'require'</div><div> /cdi/fs157/scripts/cdi_scripts/cdi_main_start.lua:2: in main chunk</div>
</div><div><br></div><div><br></div><div>First few lines of the script in question:</div><div>################################</div><div><div>#!/usr/bin/lua</div><div>require "luasql.mysql"</div><div>-- I also tried to call module like statement below</div>
<div>-- luasql = require "luasql.mysql"</div><div>fs_api = freeswitch.API();</div><div><br></div><div>dofile "/cdi/cdi_scripts/vars.lua"</div><div>dofile "/cdi/cdi_scripts/maininclude.lua"</div>
</div><div><br></div><div>Shell test script that works</div><div>#######################################</div><div><div>#!/usr/bin/lua</div><div>luasql = require "luasql.mysql"</div><div><br></div><div>env = assert (luasql.mysql())</div>
<div>con = assert (env:connect("database","username","password","162.21X.XXX.144"))</div><div>cur = assert (con:execute"SELECT * FROM xxx_acct_did")</div><div>row = cur:fetch ({}, "a")</div>
<div><br></div><div>while true do end</div><div>while row do</div><div><br></div><div>print(string.format("DID: %s, Route: %s", row.did, row.route))</div><div> row = cur:fetch (row, "a")</div><div>end</div>
<div>cur:close()</div><div>con:close()</div></div><div><br></div><div>Output of the script above:</div><div>###################################</div><div><div>DID: 18155516741, Route: <a href="http://8171111741@108.111.175.183:5066">8171111741@108.111.175.183:5066</a></div>
<div>DID: 19755514964, Route: <a href="http://9721111964@173.111.252.22:5066">9721111964@173.111.252.22:5066</a></div><div>DID: 19155515245, Route: <a href="mailto:9171111245@150.111.194.215">9171111245@150.111.194.215</a></div>
<div>DID: 19755516483, Route: <a href="http://9721111483@173.111.252.22:5066">9721111483@173.111.252.22:5066</a></div><div>DID: 12155516793, Route: <a href="http://2141111793@108.111.175.183:5066">2141111793@108.111.175.183:5066</a></div>
<div>DID: 18755519608, Route: <a href="http://8771111608@173.111.252.22:5066">8771111608@173.111.252.22:5066</a></div><div>DID: 18655518946, Route: <a href="http://8771111608@192.111.146.243:5199">8771111608@192.111.146.243:5199</a></div>
<div>DID: 19755517847, Route: <a href="http://8171111741@108.111.175.183:5066">8171111741@108.111.175.183:5066</a></div><div>DID: 15155510762, Route: <a href="http://5101111762@173.111.252.22:5066">5101111762@173.111.252.22:5066</a></div>
<div>DID: 14655512043, Route: <a href="http://4691111043@173.111.252.22:5066">4691111043@173.111.252.22:5066</a></div><div>DID: 16155519638, Route: <a href="http://6191111638@173.111.252.22:5066">6191111638@173.111.252.22:5066</a></div>
<div>DID: 14655512044, Route: <a href="http://4691111044@173.111.252.22:5066">4691111044@173.111.252.22:5066</a></div><div>DID: 18755511623, Route: <a href="http://8171111741@173.111.252.22:5066">8171111741@173.111.252.22:5066</a></div>
<div>DID: 18755511624, Route: <a href="http://8771111608@199.111.249.94:5199">8771111608@199.111.249.94:5199</a></div><div>DID: 19725550001, Route: <a href="http://9721111001@173.111.252.22:5066">9721111001@173.111.252.22:5066</a></div>
<div>DID: 16305512270, Route: <a href="http://8171111741@108.111.175.183:5066">8171111741@108.111.175.183:5066</a></div><div>DID: 14695512042, Route: <a href="http://8171111741@162.111.160.145:5066">8171111741@162.111.160.145:5066</a></div>
</div><div><br></div><div>luasql file path:</div><div>###############################################</div><div><br></div><div><div>[root@rch-vmli ~]# ls -larth /usr/local/lib/lua/5.2/luasql/mysql.so</div><div>-rwxr-xr-x 1 root root 18K Jan 6 10:35 /usr/local/lib/lua/5.2/luasql/mysql.so</div>
</div><div><br></div><div><br></div><div>FS Info:</div><div>######################################</div><div>FreeSWITCH Version 1.5.8b+git~20140106T145044Z~8d30da28d7~32bi<br></div><div>Lua version 5.2.2</div></div>