[Freeswitch-users] connecting to mysql using lua

Javier Aristizábal javieraristizabal at gmail.com
Mon Feb 9 07:03:28 PST 2009


Hi. Well you need to install luasql, and work only with lua 5.0 or major.

You need a ODBC connection to MySQL.

And there is an lua script example:
============================================================
#!/usr/local/bin/lua
require "luasql.mysql"

env = assert (luasql.mysql())
con = assert (env:connect("DB","user","password","localhost))
cur = assert (con:execute"SELECT id, name FROM test")
row = cur:fetch ({}, "a")
while row do
  print(string.format("Id: %s, Name: %s", row.id, row.name))
  -- reusing the table of results
  row = cur:fetch (row, "a")
end



cur:close()
con:close()
env:close()
==========================================================

regards
javar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20090209/ab98f942/attachment-0002.html 


More information about the FreeSWITCH-users mailing list