Hello,
You'll have to have a working odbc connection, as mentioned by Steven, but
then here's a Lua code snippet to test your stuff:
-- connect to DB via ODBC
local dbh = freeswitch.Dbh("odbc://freeswitch:freeswitch:PASS")
if dbh:connected() == false then
freeswitch.consoleLog("error", " Cannot connect to database.\n")
return
end
-- looping through the db results
freeswitch.consoleLog("info", " Looping through the DB results")
sql_query = "SELECT id,name FROM your_table LIMIT 10;"
dbh:query(sql_query, function(row)
-- do whatever you want with row.FIELD_NAME, for instance:
freeswitch.consoleLog("info", "id:" .. tostring(row.id))
end)
Hope it helps ;)
Florent
Post by Aqs YounasThanks for your quick reply. I give it a try.
Post by Steven AyreConfigure an ODBC connection to the database, then use freeswitch.Dbh
from lua
https://wiki.freeswitch.org/wiki/DSN
https://wiki.freeswitch.org/wiki/Mod_lua#freeswitch.Dbh
Post by Aqs YounasHello, Users
i am newbie to freeswitch.I want to write lua script for querying data
for mysql database that i could use in lua script.
Could someone please specify me how to do this with small exemplary lua
script code.
or
1.) How to make freeswitch connect to mysql for querying data
2.) All steps in this regard.
Thanks
_________________________________________________________________________
consulting at freeswitch.org
http://www.freeswitchsolutions.com
Official FreeSWITCH Sites
http://www.freeswitch.org
http://confluence.freeswitch.org
http://www.cluecon.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server
http://www.cudatel.com
FreeSWITCH-users mailing list
FreeSWITCH-users at lists.freeswitch.org
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org
_________________________________________________________________________
consulting at freeswitch.org
http://www.freeswitchsolutions.com
Official FreeSWITCH Sites
http://www.freeswitch.org
http://confluence.freeswitch.org
http://www.cluecon.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server
http://www.cudatel.com
FreeSWITCH-users mailing list
FreeSWITCH-users at lists.freeswitch.org
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org
_________________________________________________________________________
consulting at freeswitch.org
http://www.freeswitchsolutions.com
Official FreeSWITCH Sites
http://www.freeswitch.org
http://confluence.freeswitch.org
http://www.cluecon.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server
http://www.cudatel.com
FreeSWITCH-users mailing list
FreeSWITCH-users at lists.freeswitch.org
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20140917/6459b26a/attachment.html