I’ve been administering Asterisk servers for many years and everyday I’m learning something new. As the size of the projects have gotten bigger, so have the demands of my customers. One common request is database integration. In the past I’ve used external AGI scripts to run database queries to return values to Asterisk. But more recently I’ve been avoiding AGI in favor of direct access SQL. This is achieved by building ODBC modules into Asterisk at build time. Let me tell you, it’s worth it!
Asterisk & ODBC provide the ability to easily update and retrieve data by defining SQL statements as special variables that can be called from the dial plan. For instance, we could bill ‘long distance’, take credit cards and let Asterisk access other types of information. In my tutorial we will configure Asterisk to dial a variable that represents a SQL statement. This could also be done by calling an AGI script, but why do the extra work?
This ‘How to’ is specifically geared towards MySQL. However, if you set the up the ODBC driver correctly you can use any SQL server you like. Which leads me to my next thought, before you start, make sure ODBC is set up correctly. Follow one of my previous tutorials:
Once you do this we are ready to continue…
The goals of this post:
- create MySQL table with example data
- configure res_odbc.conf
- configure func_odbc.conf
- configure extensions.conf for query