Asterisk and Database


we configured odbc with mariaDB. All seems ok about connectivity (isql with database is ok, odbc show into cli is ok)

We took some times to read about Asterisk and external database but i guess we misunderstood something (many thing in fact :slight_smile: )
→ If you have good link, that would be greatly appreciated!

We first thought that asterisk will “naturally” use mariadDb instead of sqlite, but it keeps on using sqlite.
Using application like “DB” into diaplan still use sqlite
Then we found that there is a file called “extconfig.conf” where you can choose what to put in datase and which database.

There is no way to tell asterisk “please use mariadb where you were using sqlite” ?
As a second step, we may use database to store other things (like pjsip user or so) but for the time beeing we just want to replace sqlite by mariadb

Thanks for your help

No, the AstDB (the DB functions, plus other users in Asterisk) always uses sqlite. It’s meant as a persistent local storage mechanism. There is no mechanism to swap it for something else unless you change the code itself.

1 Like

Ok thanks for these info jcolp !

When doing a “database show” there are many “registrar” and “subcription_persistence” keys. These are for asterisk internal purpose i guess, but are we able to tell asterisk to use mariaDB for that ? Is that useful?

We are also using astDB for our purpose, to store info about user (for example DND yes or no). My understanding, if using mariaDB, is that we can not use application DB anymore we have to build our request into func_odbc.conf to read or write our DND state, correct ?


Those are from PJSIP. They can be stored in a different database using realtime. If you want to store things like DND in another database then yes, you’d have to use something such as func_odbc to do so.

1 Like

i have some problem to understand how to use the function

i did it under func_odbc

readsql=SELECT dndState FROM asterisk.usersOptions WHERE asteriskID='${SQL_ESC(${ARG}1))}'
writesql=UPDATE asterisk.usersOptions SET dndState='${SQL_ESC(${VAL1})}' WHERE asteriskID='${SQL_ESC(${ARG1})}'

but into dialpaln, how do i read or write using ODBC_DND-STATE ?
I tried thinks like that (this is only for tests purpose, set or get DND value) :

exten = _110,1,Answer()
same = n,playback(de-activated)
same = n,set(ODBC_DND-STATE(101)=0)
same = n,hangup

exten = _111,1,Answer()
same = n,playback(activated)
same = n,set(ODBC_DND-STATE(101)=1)
same = n,hangup

exten = _112,1,Answer()
same = n,playback(do-not-disturb)
same = n,playback(${ODBC_DND-STATE(101)})
same = n,hangup

Sure i misused it, and i misunderstand something !

In fact it is ok !
Just need to realod asterisk, not only dialplan

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.