Mod spidermonkey odbc
From FreeSWITCH Wiki
Contents |
SpiderMonkey ODBC
Freeswitch supports unixodbc, but requires a special compilation in order to support calls made into this library.
- First download and install unixodbc. See below if you are struggling with this step. Make sure to install headers, libraries and source for the unixodbc library set.
- Uncomment the
languages/mod_spidermonkey_odbcline within themodules.conffile. - Compile core odbc support into freeswitch.
./configure --enable-core-odbc-support make all install
Chris 13:08, 29 June 2007 (EDT) Please note that as of this writing, I found issues with the way -lodbc is being added into the gcc command line. I am still attempting to weed out the issue and will be posting a fix within the next week. My current workaround includes editing the root Makefile.am and editing the mod_spidermonkey_odbc/Makefile file. I enforce compilation with -lodbc -L/usr/local/lib in that order and everything seems to compile.
Chris 17:30, 4 July 2007 (EDT) [http://jira.freeswitch.org/browse/FSBUILD-8] resolution posted.
unixodbc
32 bit platform
Debian
- For Debian, if the spidermonkey_odbc module does not compile you can try to install the package unixodbc-dev - it compiled just fine for me afterwards.
aptitude install unixodbc-dev
Other
- Download latest version of unixodbc.
-
tar -xvzf unixodbc*.tar.gz - Run
./configure --enable-gui=no - Run
make - Run
make installRun as root user
-
- Run make for freeswitch.
64 bit platform
Other
- Download latest version of unixodbc.
-
tar -xvzf unixodbc*.tar.gz - Run
./configure --enable-gui=no - Run
make - Run
make installRun as root user
-
- Run make for freeswitch.
Errors
Debian 64 Bit
- Chris 21:40, 26 June 2007 (EDT) Debian etch seems to have 64 bit OS mismatch with the unixodbc library. I used aptitude to download the development and compiled version only to find that they were compiled for 32 bit. Here are the facts and a fix for those that need a helping hand.
MaxPowerSoft001:/home/MaxPowerSoft/freeswitch/freeswitch# uname -a Linux MaxPowerSoft001 2.6.18-4-amd64 #1 SMP Mon Mar 26 11:36:53 CEST 2007 x86_64 GNU/Linux
- Compiling freeswitch after uncommenting spidermonkey modules within modules.conf rendered:
mod_spidermonkey_odbc.c:369: warning: passing argument 2 of âSQLRowCountâ from incompatible pointer type mod_spidermonkey_odbc.c:378: warning: passing argument 7 of âSQLDescribeColâ from incompatible pointer type mod_spidermonkey_odbc.c:373: warning: unused variable âColumnSizeâ mod_spidermonkey_odbc.c:372: warning: unused variable âNullableâ mod_spidermonkey_odbc.c:372: warning: unused variable âDecimalDigitsâ mod_spidermonkey_odbc.c:372: warning: unused variable âDataTypeâ mod_spidermonkey_odbc.c:372: warning: unused variable âNameLengthâ
FIX:
-
aptitude remove unixodbc-dev libodbcinstq1c2 unixodbc(If previously installed.) - Download latest version of unixodbc.
-
tar -xvzf unixodbc*.tar.gz - Run
./configure --enable-gui=no - Run
make - Run
make installRun as root user
-
- Run make for freeswitch.
General Configuration
GUI Installation
- Run
ODBCConfig.
Manual Installation
[Reading material on manual configuration]
- Add the following with the correct information into your odbc.ini file located at
/usr/local/etc/odbc.ini.
[maxpowersoft_odbc] Driver=MySQL SERVER=localhost PORT=3306 DATABASE=myDatabase Socket = /var/run/mysqld/mysqld.sock
- Create a template_file containing:
[MySQL] Description = ODBC for MySQL Driver = /usr/local/lib/libmyodbc3.so UsageCount = 2
- Run the following to add the information into the odbcinst.ini
-
odbcinst -i -d -f template_file
-
- Test your ODBC setup by running the utility
isql-
isql maxpowersoft_odbc myUser myPass
-
FreeSwitch ODBC Configuration
After a successful compilation and installation of mod_spidermonkey_odbc make sure to modify the configuration files as follows prior to executing freeswitch.
- Edit: conf/autoload_configs/spidermonkey.conf.xml
- Uncomment:
<load module="mod_spidermonkey_odbc"/>
- Uncomment:
ODBC Example
use("ODBC");
var DSN="my_odbc_conn";
var DB_USER="my_username";
var DB_PASS="my_password";
var db = new ODBC(DSN, DB_USER, DB_PASS);
db.connect();
var digits = "9998"; //an example pin code.
var sql = "SELECT c.name, c.phone FROM user u, contact c WHERE u.userid=c.userid AND u.pin=\""+digits+"\";";
db.exec(sql);
while (db.nextRow()) {
row = db.getData();
console_log("notice", "CONTACT FOUND " + row["name"] + " " + row["phone"] + "\n");
}
db.close(); /* shown as an example, not necessary. As the script finishes execution the system will automatically release odbc resources. */
- Note, Freeswitch needs to be run under the same user that has a .odbc.ini in the root of the home folder. (ex: /home/fs/.odbc.ini)
