O'Reilly logo

FreeSWITCH 1.6 Cookbook by Giovanni Maruzzelli, Michael S Collins, Anthony Minessale II

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Connecting to an external database

Connecting to databases can be done using ODBC bindings for Lua, or native Lua drivers for databases.

Another way to connect to databases—the preferred way—is to create HTTP queries from Lua and leave the HTTP server (or servers) the burden of managing connection pools, scalability, concurrence, and so on with tried and true well-known techniques.

Here, we'll see this preferred way.

Getting ready

Create a dialplan extension "12348" that will call our last Lua script. Edit the /usr/local/freeswitch/conf/dialplan/default/04_database.xml file:

<include> <extension name="Connect to DataBase"> <condition field="destination_number" expression="^(12348)$"> <action application="answer"/> <action application="sleep" data="1000"/> ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required