Connecting to MySQL database


What is the greatest way to connect a MyQL database ?

I’m currently using Asterisk 11, we plan to make lot of MySQL queries in the dialplan in order to find customers ids, blacklisted numbers, …

I tried odbc via mysql odbc driver (via available packages for debian 8) but it seems to be not quite stable. For a 250 simultaneous calls server, asterisk randomly crashes…
Seems also that mysql odbc drivers are not longer maintained, I saw some topics where people said that even with latest MySQL/MariaDB odbc connector and the latest unixodbc asterisk still crashes.

There is a MYSQL dialplan application in asterisk 11 but seems to be depreciated.

Thanks in advanced !

If you want to do it from the dialplan use System cmd


> > same=>n,System(mysql --user=root --password='789456' conferences -e "update recordings set path='${path:0:-1}' where Id='${Id}'")


Ok thanks

Maybe Shell application instead. (If I want to get values in a variable).
Hope the load will not be to heavy.

If using shell to read values remove the last character from the variable returned



Thanks for your reply :).
It won’t work for 2 reasons :

  • mysql-client returns lots of unneeded characters with columns names etc…
  • SHELL command on dialplan has a huge impact on CPU load.


same=>n,Set(dest=${SHELL( mysql -h --user=root --password='105888' --skip-column-names asterisk -e "select src from cdr limit 1")})

**-skip-column-names ** ( remove colum name)

${dest:0:-1} ( Clean the variable)

Related to system resources I have been using this method with no issue on the resouces part, but it is up to you