Asterisk Accessing a MySQL db

I’m looking to have Asterisk pull a customer id out of a MySQL db that will later be stored in the cdr (the cdr part I’m fine with, I just can’t get Asterisk to get into the db). I tried following some instructions but they appear to be a little dated. Here is the part with mysql:

exten => s,1,MYSQL(Connect connid localhost dbuser* dbpass* dbname*) *real info added
same => n,MYSQL(Query resultid ${connid} SELECT cust_id FROM store_one WHERE ext=235)
same => n,Verbose(${resultid})

I get this error:
WARNING[6644]: pbx.c:4236 pbx_extension_helper: No application ‘MYSQL’ for extension (test, s, 1)

Is there another place that needs something enables/ installed for Asterisk to use MySQL? I was under the impression it was bundled with Asterisk. What am I missing?

Thanks!

I suggest to use AGI (Asterisk Gateway Interfacing) to achieve the same thing.
I did previously and it was successful.

or you could use odbc

I wrote a blog article about that on controlaltdieliet.be/blog/?p=95

Or you could recompile asterisk to enable the app_mysql

I would really like to use the MYSQL command right in Asterisk. Navaismo, you said I could

I’m assuming this is the real reason my first post isn’t working after you said it. Would you know of how to enable it for a recompile?

Thanks

Install asterisk-addons and check

[quote=“milksnake12”]I would really like to use the MYSQL command right in Asterisk. Navaismo, you said I could

I’m assuming this is the real reason my first post isn’t working after you said it. Would you know of how to enable it for a recompile?

Thanks[/quote]

What version of asterisk are you using? And how you installed it?

I’m running Asterisk 1.8.11-cert1 and I installed it with wget from the Asterisk site

wget can only download it, not install it!

Did you do:

./configure
make menuconfig
make
make install
make configs
make samples

assuming you can do this with cert versions. make menuconfig is where you enable things like SQL, and also which will tell you if you have missing dependencies.

Another option is to install the func_odbc.so module. This will let you populate the file func_odbc.conf with queries that can then be exposed via wrappers inside the dialplan.

It might seem appealing at first to do mysql directly in the dialplan, but as complexity increases you’ll really really wanna factor all those mysql calls out into some external entity. Also, just as a best practice you never really want raw direct access to your RDBMS.