Using ODBC in the core – FreeSWITCH Wiki

2. Install the unixODBC driver

You will need to obtain the ODBC for your chosen database. Instructions for obtaining the drivers for MySQL or PostgreSQL are provided below.

For MySQL:

sudo apt-get install libmyodbc

For PostgreSQL

sudo apt-get install odbc-postgresql

3. Configure /etc/odbc.ini & /etc/odbcinst.ini

Add the following with the correct information into your odbc.ini file located at /etc/odbc.ini
/etc/odbc.ini for MySQL

ImportantIf you are running on a 32-bit Linux installation, use the following configuration, but change all references to /usr/lib64/ in to /usr/lib/ in the examples provided.

[freeswitch]
Driver = /usr/lib64/odbc/libmyodbc.so
SERVER = localhost
PORT = 3306
DATABASE = freeswitch # insert your chosen database name here
OPTION = 3
USER = root # insert your db username
PASSWORD = password # insert your db password here

/etc/odbcinst.ini for MySQL

[MySQL]
Description = MySQL driver
Driver = /usr/lib64/odbc/libmyodbc.so
Setup = /usr/lib64/odbc/libodbcmyS.so
UsageCount = 1
FileUsage = 1
Threading = 0

If it is available on your system, you must use Driver = /usr/lib64/odbc/libmyodbc_r.so in your odbcinst.ini.

Also note, (see bug below on bottom of page); If you are using the FreeSWITCH pooled resources, then you definitely need Threading = 0 for high call volume. What this does is it « disables a global mutex in the ODBC core that only allows 1 concurrent operation per process regardless of the concurrent connections. » (i.e. It slows down when you have too many connections trying at one time)

As far as has been tested, when making changes to the odbcinst.ini, you do not need to restart FreeSWITCH to effect the changes.
/etc/odbc.ini for PostgreSQL

ImportantIf you are running on a 32-bit Linux installation, use the following configuration, but change all references to /usr/lib64/ in to /usr/lib/ in the examples provided.

[freeswitch]
; WARNING: The old psql odbc driver psqlodbc.so is now renamed psqlodbcw.so
; in version 08.x. Note that the library can also be installed under an other
; path than /usr/local/lib/ following your installation.
Driver = /usr/lib64/odbc/psqlodbcw.so
Description=Connection to LDAP/POSTGRESQL
Servername=localhost # insert database host IP
Port=5432 # insert database port
Protocol=6.4
FetchBufferSize=99
Username=postgres # insert your db username here
Password=password # insert your password here
Database=freeswitch # insert your chosen db here
ReadOnly=no
Debug=1
CommLog=1

/etc/odbcinst.ini for PostgreSQL

[PostgreSQL]
Description = PostgreSQL driver for Linux & Win32
Driver = /usr/lib64/odbc/psqlodbcw.so

4. Testing your connection

Once you’ve set up the .ini files in and have your ODBC drivers installed, you can test your ODBC connection is working correctly by entering:

isql -v freeswitch

If a connection is successfully established you should see something similar to:

+—————————————+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+—————————————+
SQL>

5. Compile Freeswitch & Set Modules to Use ODBC

You will need to compile/recompile freeswitch so that ODBC is detected and included within the installation. You will then need to edit the freeswitch configuration to utilize the ODBC connection you just defined.

See [Compile FreeSWITCH with ODBC support] below for more information.