[Asterisk-Users] cdr translation

Carlos Alperin calperin at senecacom.net
Tue Jan 17 03:07:07 MST 2006


Merci, Jean databases are not my speciality.

This save me a lot to read. 

Regards,

Carlos

-----Original Message-----
From: asterisk-users-bounces at lists.digium.com
[mailto:asterisk-users-bounces at lists.digium.com] On Behalf Of Jean-Michel
Hiver
Sent: Tuesday, January 17, 2006 4:52 AM
To: Asterisk Users Mailing List - Non-Commercial Discussion
Subject: Re: [Asterisk-Users] cdr translation

Carlos Alperin a écrit :

> Did someone made or implement an script to move all the info from the 
> standar cdr format to a PostgreSQL or MySQL?
>

Here's what I did:


To create a CDR table:

create table cdr (
        accountcode varchar (30) NOT NULL,
        src varchar(64),
        dst varchar(64),
        dcontext varchar(32),
        clid varchar(32),
        channel varchar(32),
        dstchannel varchar(32),
        lastapp varchar(32),
        lastdata varchar(64),
        calldate timestamp NOT NULL,
        callpickup timestamp ,
        callhangup timestamp ,
        duration int(8) unsigned default NULL,
        billsec int(8) unsigned default NULL,
        status varchar(32),
        userfield varchar(128),
        PRIMARY KEY (accountcode)
);


To update the CDR table from the Master.csv file

cat /var/log/asterisk/cdr-csv/Master.csv | \
egrep -v '^"",' | \
sed 's/,,/,"",/;s/\(^.*$\)/REPLACE INTO cdr VALUES\(\1\);/' | \
mysql -u root <your_db_name>


Cheers,
Jean-Michel.

_______________________________________________
--Bandwidth and Colocation provided by Easynews.com --

Asterisk-Users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users




More information about the asterisk-users mailing list