Inserting CDRs into a backend database
Frequently it is necessary to put CDR information into a database such as MySQL, PostgreSQL, or other SQL databases. FreeSWITCH does not support writing CDRs directly to a database (the decision not to write directly to a database is an engineering, not a technical limitation). This recipe discusses the simple method of writing SQL-based CSV files and then using those to update a backend database.
Getting ready
Of course, you will need a database in which to store your files. Any SQL-compliant database will work as long as you can use the command line to execute SQL statements. Create a database for your CDRs and allow any necessary access. This is completely dependent upon the type of database you have—consult your database documentation for specific instructions.
You will also need a table for the CDRs. The following CREATE
TABLE
syntax for a PostgreSQL database will work for the existing sql
template in cdr_csv.conf.xml
:
CREATE TABLE cdr ( caller_id_name...