Discussion:
[Freeswitch-users] lua script for mysql
Aqs Younas
2014-09-16 17:41:53 UTC
Permalink
Hello, 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20140916/90d6b8d3/attachment.html
Steven Ayre
2014-09-16 19:21:19 UTC
Permalink
Configure 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 Younas
Hello, 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20140916/1628333d/attachment.html
Aqs Younas
2014-09-16 19:37:33 UTC
Permalink
Thanks for your quick reply. I give it a try.
Post by Steven Ayre
Configure 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 Younas
Hello, 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20140917/ab11b52c/attachment-0001.html
Florent Krieg
2014-09-17 10:29:25 UTC
Permalink
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 Younas
Thanks for your quick reply. I give it a try.
Post by Steven Ayre
Configure 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 Younas
Hello, 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
Continue reading on narkive:
Loading...