Asterisk application DBQuery
With DBQuery you can access your Mysql Database and query it for the needed data, or update data in your Mysql Database. It is also possible to register DBQuery as cdr backend - so you can define your own sql statement for writing cdr data. DBQuery does use the MysqlPool Resource to get a connection handle to a MySQL Database, so you achive load balancing and a fail save environment with it.Compile it:
For compiling it you do need the mysql client libraries and header files. Asterisk and its header files are also required. If you do not have installed asterisk in the default directories, then you have to edit the Makefile and make changes to the following variables.
ASTERISKINCDIR
Set ASTERISKINCDIR variable to the directory containing the sources of Asterisk PBX.
ASTERISKMODDIR
Set ASTERISKMODDIR variable to the directory where ASTERISK's modules reside. The modules will be installed in this directory.
ASTERISKETCDIR
Set ASTERISKETCDIR variable to the directory where ASTERISK's configuration files reside. The config files will be installed in this directory.
Configure it:
Example config file can be found in the doc subdirectory.
There are two categories, the category queries and the category cdr-backend.
In queries you have to configure the queries which should be useable by DBQuery.
callforwarding=SELECT destination FROM callforwarding WHERE extension='%s' AND class='%s'
In cdr-backend you can define the sql query which should get used for writing the cdr entry, the server which should get used preferred and with the option enabled you can enable or disable the cdr-backend.
Extensions example:
Example usage for DBQuery:
exten => 12,1,DBQuery(callforwarding,(${EXTEN}|unconditional),(CF_DESTINATION))
This statement will execute the sql query defined in the dbquery.conf file for the key callforwarding. It will substitute each %s with an argument provided. So the statement which will get executed will look like:
SELECT destination FROM callforwarding WHERE extension='12' AND class='unconditional'
The returned value will get placed in the channel variable ${CF_DESTINATION}
For more information just take a look at http://www.yosd.at/
Asterisk | Applications | Functions | Variables | Expressions | Asterisk FAQ
Page Changes
dbquery problem
Test*CLI> load app_dbquery.so
Unable to load module app_dbquery
Jul 2 17:32:58 WARNING5831: loader.c:325 __load_resource: /usr/lib/asterisk/modules/app_dbquery.so: undefined symbol: get_sql_connection
Does anybody know what the problem could be ?
Problem solved.
before load app_dbquery.so we need to load res_mysqlpool.so
dbquery problem
dbquery problem