[Freeswitch-users] lua script for mysql
Florent Krieg
flokrrr at gmail.com
Wed Sep 17 14:29:25 MSD 2014
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
2014-09-16 21:37 GMT+02:00 Aqs Younas <aqsyounas at gmail.com>:
> Thanks for your quick reply. I give it a try.
>
> On 17 September 2014 00:21, Steven Ayre <steveayre at gmail.com> wrote:
>
>> 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
>>
>> On 16 September 2014 18:41, Aqs Younas <aqsyounas at gmail.com> wrote:
>>
>>> 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
>>>
>>> _________________________________________________________________________
>>> Professional FreeSWITCH Consulting Services:
>>> consulting at freeswitch.org
>>> http://www.freeswitchsolutions.com
>>>
>>> Official FreeSWITCH Sites
>>> http://www.freeswitch.org
>>> http://confluence.freeswitch.org
>>> http://www.cluecon.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
>>>
>>
>>
>> _________________________________________________________________________
>> Professional FreeSWITCH Consulting Services:
>> consulting at freeswitch.org
>> http://www.freeswitchsolutions.com
>>
>> Official FreeSWITCH Sites
>> http://www.freeswitch.org
>> http://confluence.freeswitch.org
>> http://www.cluecon.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
>>
>
>
> _________________________________________________________________________
> Professional FreeSWITCH Consulting Services:
> consulting at freeswitch.org
> http://www.freeswitchsolutions.com
>
> Official FreeSWITCH Sites
> http://www.freeswitch.org
> http://confluence.freeswitch.org
> http://www.cluecon.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
Join us at ClueCon 2016 Aug 8-12, 2016
More information about the FreeSWITCH-users
mailing list