LuaSQL is a simple interface from Lua to a DBMS - http://keplerproject.org/luasql/
It is also possible to use the FS ODBC support through freeswitch.Dbh, without installing LuaSQL
Since FreeSWITCH 1.4, you need to use Lua5.2 (http://www.lua.org/manual/5.2/).
For those willing to keep using Lua5.1 for backwards compatibility reasons, there is a mod_lua available in legacy directory `freeswitch/src/mod/legacy/languages/mod_lua/`
You will need to install Lua5.2, for instance on Debian7, you can run the following:
Download LuaSQL 2.3.0:
You will need to change the 'config' file to reflect your system and the DBMS to interface with.
The config file is divided into three broad sections:
- DB Name
- Paths to different libraries
- Paths to DB related libraries
First check the #2 if it matches your flavor of OS.
Then, you have to select only *one* driver to compile at a time. Suppose you want to compile MySQL, then you have to uncomment only the MySQL line from #1 and #3. All other lines in both these sections should be commented.
On RHEL / CentOS, the path for MySQL libs and include is not the same as the default config file that comes with LuaSQL.
Please make the Driver parameters changes as follows:
On x64_86 architecture, you need to change a few more things in 'config' file
Set proper values for LUA_LIBDIR, LUA_DIR , LUA_INC , DRIVER_LIBS, DRIVER_INCS
To allow compile properly, you will also need -fPIC:
Then compile and install:
If earlier you wanted to use Microsoft SQL Server earlier you would have changed the following:
Then make the Driver parameters changes as follows:
Compile and install!
LuaSQL Mysql example
Next you can do something like:
LuaSQL ODBC example
For ODBC, you need to edit the odbc.ini and odbcinst.ini (both in /etc on RHEL). A typical MySQL configuration looks like:
NOTE: I found you also need to set some environment variables for scripts to run properly
NOTE: you need to symlink the shared object (i.e., mysql.so) to /usr/local/lib/lua/5.1/luasql/mysql.so
- Script to install LuaSQL with Postgresql on Debian7 - https://gist.github.com/areski/6ab7ee00d7025a1eaa97