Getting app-daynight-toggle mode value from DB

Hello!
I have a problem. I need to get current daynight mode value via SQL query from asterisk database. But I can’t figure out where to find this value in DB.
Thanks in advance!

That value is not stored in MySQL. You would need to query the Asterisk DB, i.e.:

*CLI> database show DAYNIGHT/C0
/DAYNIGHT/C0                                      : DAY
1 results found.
1 Like

But Asterisk DB is database so it must keep this values somewhere in DB table. The question is what is this table?

The Asterisk DB is not stored in MySQL. It is a local Asterisk specific sqlite3 database.

1 Like

FreePBX uses three ‘database stores’, mysql tables in the ‘asterisk’ and ‘asteriskcdrdb’ databases, asteriskdb in an sqlite3 database that stores the ‘state’ of the PBX, and voicemail.conf that is a flat text file that is used by ‘comedian mail’ (the asterisk voicemail system)

toggle state and other machine states will always be found in the sqlite3 database.

Mysql on the other hand is used to generate the static dial-plan as you define in the GUI and then ‘reload’ but does obliquely ‘consult’ with the other two ‘data stores’

1 Like

Thanks to all for the answers!
Is there a way to access this sqlite3 database or is it possible to change FreePBX config to keep the daynight mode values in MySQL too?

you can set the database from the asterisk cli with database put <family> <key> <value> having achieved your desires, then fwconsole reload should be ‘obliquely’ observant of your changes in kvstore , but it doesn’t really matter, as Asterisk will ONLY react to the state preserved in the sqlite3 database over restarts or reloads

1 Like

Sorry, I didn’t clear explain what I need. I need to access to sqlite3 database programmatically. So I need to connect to it e.g. with ODBC driver. Is there any way to do this?

You can connect to that database with the standard sqlite3 client, if you do so while asterisk is running, you run the risk of corrupting the database because the access is ‘thread safe’ but not multi-user safe,. In your interest, just either shut down asterisk first , or embed your query within a call to 'rasterisk -x ‘database query xxxxxxxxx’

(BTDT)!

1 Like

Or just
asterisk -rx "database get DAYNIGHT C0"

Thanks, but I need to do it using SQL query to sqlite3 to create a report that also uses data from MySql. As I see there is no safe way to access sqlite3 with running asterisk.

Sending the ‘database get’ command to Asterisk does do it safely. If whatever language you are using can execute a shell command, you can fetch the desired result.

that is not true,

rasterisk -x "database query 'select x from y where z'"

works fine and safely wraps the query into a safe
‘call’

1 Like

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