Asterisk with MySQL via ODBC connected but not writing in DB

Hello everyone,
I’m trying to get Asterisk working with ODBC/MYSQL.
My SQL CDR table is created and is connected with Asterisk via :
odbc.ini :

[asterisk-mysql]
Description = MySQL connection to ‘asterisk’ database
Driver = MySQL
Database = my_database
Server = localhost
UserName = my_username
Password = xxxxxxx
Port = 3306

odbcinst.ini :

[MySQL]
Description = ODBC for MySQL
Driver = /usr/lib/x86_64-linux-gnu/odbc/libmyodbc8a.so
Setup = /usr/lib/x86_64-linux-gnu/odbc/libmyodbc8S.so
FileUsage = 1

res_odbc.conf :

[asterisk-mysql]
enabled => yes
dsn => asterisk-mysql
username => my_username
password => xxxxxxxx
pre-connect => yes

cdr.conf :

[general]
enable=yes
unanswered = yes

congestion = yes
[csv]
usegmtime=yes
loguniqueid=yes
loguserfield=yes
accountlogs=yes
newcdrcolumns=yes
[odbc]
usegmtime=yes
loguniqueid=yes
loguserfield=yes
accountlogs=yes

The result of odbc show :

ODBC DSN Settings
-----------------

  Name:   asterisk-mysql
  DSN:    asterisk-mysql
    Number of active connections: 1 (out of 1)
    Logging: Disabled

And here is my table :

CREATE TABLE cdr (
	calldate datetime NULL ,
	clid varchar(80) NOT NULL default '',
	src varchar(80) NOT NULL default '',
	dst varchar(80) NOT NULL default '',
	dcontext varchar(80) NOT NULL default '',
	channel varchar(80) NOT NULL default '',
	dstchannel varchar(80) NOT NULL default '',
	lastapp varchar(80) NOT NULL default '',
	lastdata varchar(80) NOT NULL default '',
	duration int(11) NOT NULL default '0',
	billsec int(11) NOT NULL default '0',
	disposition varchar(45) NOT NULL default '',
	amaflags int(11) NOT NULL default '0',
	accountcode varchar(20) NOT NULL default '',
	uniqueid varchar(32) NOT NULL default '',
	userfield varchar(255) NOT NULL default ''
);

I have no log in Asterisk CLI, any advice about the issue ?
Thanks :slight_smile:

I made a guide a long time ago , comparing your configuration with mine, only discrepancy is you don’t have

/etc/asterisk/cdr_adaptive_odbc.conf

[asterisk-mysql]
connection=asterisk-mysql
table=cdr
alias start => calldate

the run these 2 commands

module reload res_odbc.so
module reload cdr_adaptive_odbc.so

1 Like

Thanks for your answer!
I finally got fixed, I made a NodeJS script to look at the csv file, and import it in a custom table in my db.
It is an alternative solution

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