Upgrade 3CX to v18 and get it hosted free!

Asterisk app_dbodbc

Author image

app_dbodbc

This is original Brian’s re-implementation of the Asterisk database using unixODBC.
This allows for easy creation of dialplan modifiers that link into a GUI with a back-end database.

Install

rpm -ivh unixODBC*rpm
rpm -ivh MyODBC*rpm

cp app_dbodbc.c /usr/src/asterisk/apps/

vi /usr/src/asterisk/apps/Makefile +28
add in the end of line: app_dbodbc.so

vi /usr/src/asterisk/apps/Makefile +110
app_dbodbc.so: app_dbodbc.o
$(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} -lodbc

cd /usr/src/asterisk
make
make install

Configure

This assumes using MySQL database on RedHat – will vary for other DBs & slightly for other OS’s.

Configure MySQL:

  • Add a database called ‘asterisk’
  • Create a user with full read/write access to this database
  • Add a table within this database called ‘astdb’
  • Add 3 fields to the structure of this table: ‘astfamily’, ‘astkey’ & ‘astvalue’

vi /etc/odbcinst.ini
[MySQL]
Description = ODBC for MySQL
Driver = /usr/lib/libmyodbc.so
Setup = /usr/lib/libodbcmyS.so
FileUsage = 1

vi /etc/odbc.ini
[MySQL-asterisk]
Description = MySQL Asterisk database
Trace = Off
TraceFile = stderr
Driver = MySQL
SERVER = localhost
USER =
PASSWORD =
PORT = 3306
DATABASE = asterisk

Test ODBC:
isql -v MySQL-asterisk myusername mypassword

vi /etc/asterisk/odbc.conf
[global]
dsn=MySQL-asterisk
username=myusername
password=mypassword

Usage

  • ODBCget(varname=family/key):

Retrieves a value from the Asterisk database and stores it in the given variable. Always returns 0. If the requested key is not found, jumps to priority n+101 if available.

  • ODBCput(family/key=value):

Stores the given value in the Asterisk database. Always returns 0.

  • ODBCdel(family/key):

Deletes a key from the Asterisk database. Always returns 0.

  • ODBCdeltree(family[/keytree]):

Deletes a family or keytree from the Asterisk database. Always returns 0.

and if you use the extented version:

  • ODBCLookupCIDName:

Looks up Caller*ID number on the the active channel in the ODBC database (family ‘cidname’) and sets the Caller*ID name. Does nothing if no Caller*ID was received on the channel. This is useful if you do not subscribe to Caller*ID name delivery, or if you want to change the names on some incoming calls. Always returns 0.

  • ODBCLookupBlacklist:

Looks up the Caller*ID number on the active channel in the ODBC database. If the number is found, and if there exists a priority n + 101, where ‘n’ is the priority of the current instance, then the channel will be setup to continue at that priority level. Otherwise, it returns 0. Does nothing if no Caller*ID was received on the channel. Example: database put blacklist name/number> 1

See also



Article Reviews

Write a Review

Your email address will not be published. Required fields are marked *

Required Field. Minimum 5 characters.

Required Field. Minimum 5 characters, maximum 50.

Required field.There is an error with this field.

Required Field.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

There are no reviews for this article. Be the first one to write a review.

Related Posts:

Get 3CX - Absolutely Free!
Link up your team and customers Phone System Live Chat Video Conferencing

Hosted or Self-managed. Up to 10 users free forever. No credit card. Try risk free.

3CX
A 3CX Account with that email already exists. You will be redirected to the Customer Portal to sign in or reset your password if you've forgotten it.