Insert records to database(astdb) from file

Hello,

I’m looking for best way how to manage some values in database.
What I’m doing , conference system with confbridge. Read confid and pin from database. All this is realised but somehow confid and pin need to enter in database. I realised by
put same => n,TrySystem(bash /etc/asterisk/cl.sh) in the context for confline…
This is the content of cl.sh script
#!/bin/bash

while IFS=’,’ read -ra room;do asterisk -x “database put confline {room}/pin {room[@]:1}”;done </etc/asterisk/confline.conf 2>/dev/null >&2

all this working but every time when somebody connect to conf system in console appears
– Remote UNIX connection
– Remote UNIX connection disconnected

Is there some better way how to manage values in database? My idea is to keep all configurations in files.

You could use FUNC_ODBC and store your data in a SQL database and manage it through that.

Func_odbc is way better to use and its more transparent to see as there are many tools to talk to sql.

Basically its create a database to hold you data
then in func_odbc.conf you need to create

[myoperation]
readhandle=configuration
writehandle=configuration
readsql=select fields from whereever where condition = ‘{SQL_ESC({ARG1})}’
writesql=UPDATE whereever SET field = ‘{SQL_ESC({VAL1})}’ WHERE id = ‘{SQL_ESC({ARG1})}’

In Dial plan you would likely do a
set(HASH(name)=${ODBC_MYFUNC(field)}

1 Like

Thank you for suggestions, but I’m looking for more simple solution. No reason to install MySQL server just for 1 table with 2 columns and probably 10 records :slight_smile:

My idea is find some better way how to maintain the records in the database which come with asterisk installation.

The messeage is from the commands for the put and are normal when you do the connection to asterisk with the asterisk -x command.

You likely code do this over a ami or api call but that is out of day to day. I bet though the ami gives you some other console message on the ami login.