[Freeswitch-users] LuaSQL doesn't work in Freeswitch

Doug Vought doug.vought at gmail.com
Sun May 31 06:49:51 MSD 2015


Hi, sorry. It looks like I messed up the code. I pasted in some easier to
copy code:

api = freeswitch.API()
require"luasql.sqlite3"
env = luasql.sqlite3()
conn = env:connect("db.db")
session:answer()
query = [[INSERT INTO TEST_TABLE VALUES("0000000000")]]
session:consoleLog("info", query .. "\n")
conn:execute(query)
conn:commit()
conn:close()
env:close()
session:hangup()

----

require"luasql.sqlite3"
env = luasql.sqlite3()
conn = env:connect("db.db")
query = [[INSERT INTO TEST_TABLE VALUES("0000000000")]]
conn:execute(query)
conn:commit()
conn:close()
env:close()


On Sat, May 30, 2015 at 10:41 PM, Doug Vought <doug.vought at gmail.com> wrote:

> <https://freeswitch.org/confluence/display/FREESWITCH/Lua+with+Database>
>
> On this confluence page, it indicates that one can use LuaSQL to connect
> to a database.
>
> FreeSWITCH Version 1.4.18-1~64bit (-1 64bit)
> Lua 5.2.1
> Linux freeswitch 3.2.0-4-amd64 #1 SMP Debian 3.2.65-1+deb7u2 x86_64
>
> Utilizing the LuaSQL-sqlite3 database connector, I will attempt to INSERT,
> but the value never gets inserted.
>
> The reason I think it is freeswitch is because utilizing the same code
> (without the freeswitch hooks), the INSERT works just fine.
>
> Here's what I'm doing:
>
>
> api = freeswitch.API()
>> require"luasql.sqlite3"
>> env = luasql.sqlite3()
>> conn = env:connect("db.db")
>> session:answer()
>> query = [[INSERT INTO TEST_TABLE VALUES("0000000000")]]
>> session:consoleLog("info", query .. "\n")
>> conn:execute(query)
>> conn:commit()
>> conn:close()
>> env:close()
>> session:hangup()
>>
>
> The Lua interpreter is not throwing me any errors and the dialplan ends,
> so I assume it's working. I go into the database to see and nothing has
> been inserted.
>
> Also note: I did try to make sure I was taking locking into account by
> giving env:connect() the appropriate millisecond value, but this did not
> change anything.
>
> If I do this same thing, but without Freeswitch involved and ran by the
> Lua interpreter:
>
> require"luasql.sqlite3"
>> env = luasql.sqlite3()
>> conn = env:connect("db.db")
>
> query = [[INSERT INTO TEST_TABLE VALUES("0000000000")]]
>>
> conn:execute(query)
>> conn:commit()
>> conn:close()
>> env:close()
>>
>
>  The values are inserted.
>
> ----
>
> I am putting this here because I am assuming this is a failure on my part
> and I don't want to muck up Jira if that's the case.
>
> BUT, it would be nice to see the LuaSQL recommendation removed if doesn't
> work as expected with Freeswitch.
>
> Can anyone try this and see if they are having the same problem? Maybe we
> can save a few people some time by getting that info off of the confluence
> page if it's found not to work with multiple people :).
>
> Thanks,
> Doug
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20150530/014a1ef4/attachment-0001.html 


Join us at ClueCon 2016 Aug 8-12, 2016
More information about the FreeSWITCH-users mailing list