Discussion:
[Asterisk-Users] Storing extension prefs. in MySQL
Arnar Birgisson
2005-09-09 15:43:20 UTC
Permalink
Hello,

In the examples on voip-info.org DBSet and DBGet are used to store configuration variables such as immediate call forwarding settings etc.

I would like to store these seetings in a mysql database, so that they are more easily accessible from a user configuration page on a webserver. Since these settings need to be checked in the dialplan for each call to the extension, it seems a bit to much to have to connect, query and disconnect from mysql every time. Is there any way to keep a persistent connection to mysql that can be queried from the dialplan?

Arnar
Andreas Sikkema
2005-09-09 15:47:07 UTC
Permalink
Post by Arnar Birgisson
I would like to store these seetings in a mysql database, so
that they are more easily accessible from a user
configuration page on a webserver. Since these settings need
to be checked in the dialplan for each call to the extension,
it seems a bit to much to have to connect, query and
disconnect from mysql every time. Is there any way to keep a
persistent connection to mysql that can be queried from the
dialplan?
Well, if you do this before answering, nobody is going to
notice. Even querying during an answered call will have
hardly any outside consequences...
--
Andreas Sikkema bbned NV
Van Vollenhovenstraat 3 3016 BE Rotterdam
t: +31 (0)10 2245544 f: +31 (0)10 413 65 45
Chris A. Icide
2005-09-09 18:00:32 UTC
Permalink
Post by Andreas Sikkema
Post by Arnar Birgisson
I would like to store these seetings in a mysql database, so
that they are more easily accessible from a user
configuration page on a webserver. Since these settings need
to be checked in the dialplan for each call to the extension,
it seems a bit to much to have to connect, query and
disconnect from mysql every time. Is there any way to keep a
persistent connection to mysql that can be queried from the
dialplan?
Well, if you do this before answering, nobody is going to
notice. Even querying during an answered call will have
hardly any outside consequences...
Using the MYSQL functions from asterisk-addons....

extensions.conf

[macro-open-connection]

exten => s,1,MYSQL(Connect connid .....
exten => s,2,SetVar(OPEN-CON=1)

[macro-close-connection]

exten => s,1,GotoIf(${OPEN-CON}?5)
exten => s,5,MYSQL(Close ${connid})

Then call the open macro when you first receive a call, and make sure in
your hangup (exten => h) function you call the close macro. If you have
an include => hangup in all your contexts, the close macro will be
called anytime a hangup is received and it will close any connection you
opened for that call.

Loading...