Cdr database insert problem

Hello

I am using Asterisk 16. I want to save the records in Mysql. The CDR database fails as follows. can you help me ?

Thank you.

—% cdr_odbc.conf:

[global]
dsn=astcdr
loguniqueid=yes
dispositionstring=yes
table=cdr ;“cdr” is default table name
usegmtime=yes ; set to “yes” to log in GMT
hrtime=yes ;Enables microsecond accuracy with the billsec and duration fields
ewcdrcolumns=yes ; Enable logging of post-1.8 CDR columns (peeraccount, linkedid, sequence)

—% odbc.ini:

[astcdr]
Description = MySQL connection to database
Driver = MySQL
Database = cdr
Server = localhost
User = root
Password = ***************
Port = 3306
Socket = /var/run/mysqld/mysqld.sock

—% db_tables:

mysql> describe cdr;
±------------±-------------±-----±----±--------±------+
| Field | Type | Null | Key | Default | Extra |
±------------±-------------±-----±----±--------±------+
| accountcode | varchar(80) | YES | | NULL | |
| src | varchar(80) | YES | | NULL | |
| dst | varchar(80) | YES | | NULL | |
| dcontext | varchar(80) | YES | | NULL | |
| clid | varchar(80) | YES | | NULL | |
| channel | varchar(80) | YES | | NULL | |
| dstchannel | varchar(80) | YES | | NULL | |
| lastapp | varchar(80) | YES | | NULL | |
| lastdata | varchar(80) | YES | | NULL | |
| start | datetime | YES | | NULL | |
| answer | datetime | YES | | NULL | |
| end | datetime | YES | | NULL | |
| duration | int(11) | YES | | NULL | |
| billsec | int(11) | YES | | NULL | |
| disposition | varchar(45) | YES | | NULL | |
| amaflags | varchar(45) | YES | | NULL | |
| userfield | varchar(256) | YES | | NULL | |
| uniqueid | varchar(150) | YES | | NULL | |
| linkedid | varchar(150) | YES | | NULL | |
| peeraccount | varchar(80) | YES | | NULL | |
| sequence | int(11) | YES | | NULL | |
±------------±-------------±-----±----±--------±------+
21 rows in set (0.00 sec)

—% error:

cdr_odbc.c:159 execute_cb: cdr_odbc: Error in ExecDirect: -1, query is: INSERT INTO cdr (calldate,clid,src,dst,dcontext,channel,dstchannel,lastapp,lastdata,duration,billsec,disposition,amaflags,accountcode,uniqueid,userfield) VALUES ({ts ‘2020-03-08 21:41:41’},?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)

Can you access the database tables with isql? Have you configured res_odbc.conf? And finally, do you get a better result if you use cdr_adaptive_odbc.conf?

The schema doesn’t match what is being inserted. There is no “calldate” column.

1 Like

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