# Resolved: CDR logging to postgres database problem

**URL:** <https://community.asterisk.org/t/resolved-cdr-logging-to-postgres-database-problem/22164>\
**Category:** Asterisk Support\
**Created:** [July 25, 2008, 8:01pm UTC](https://community.asterisk.org/t/resolved-cdr-logging-to-postgres-database-problem/22164 "2008-07-25T20:01:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![scottman](https://avatars.discourse-cdn.com/v4/letter/s/6a8cbe/32.png) [@scottman](https://community.asterisk.org/u/scottman)\
**Post date:** [July 25, 2008, 8:01pm UTC](https://community.asterisk.org/t/resolved-cdr-logging-to-postgres-database-problem/22164/1 "2008-07-25T20:01:03Z")

</div>

Running Asterisk 4.6\_beta9  
brand new to asterisk; I do have it up and running, connected to a sip provider and passing calls around.

I am trying to post the cdr messages to a postgres database. Everything seems to start-up correctly and all but in the end it fails to insert the rows.

I’ve validated that the odbc connection works by logging into postgres via the odbc connection. I can see the table in postgres so I know it is there.

I even validated that I could inert rows into the cdr table in the asterisk database with the user configured to log in.

Asterisk start up I see this in the message file:

[Jul 25 12:45:36] NOTICE[26920] config.c: Registered Config Engine odbc  
[Jul 25 12:45:36] NOTICE[26920] res\_odbc.c: Connecting asterisk  
[Jul 25 12:45:36] NOTICE[26920] res\_odbc.c: res\_odbc: Connected to asterisk [asteriskConnector]  
[Jul 25 12:45:36] NOTICE[26920] res\_odbc.c: Registered ODBC class ‘asterisk’ dsn-\>[asteriskConnector]  
[Jul 25 12:45:36] NOTICE[26920] res\_odbc.c: res\_odbc loaded.

## from the CLI\> phonesys_CLI\> odbc show phonesys_CLI\> ODBC DSN Settings

Name: asterisk  
DSN: asteriskConnector  
Pooled: No\>  
Connected: Yes

phonesys\*CLI\> cdr show status  
CDR logging: enabled  
CDR mode: simple  
CDR output unanswered calls: yes  
CDR registered backend: ODBC  
CDR registered backend: Adaptive ODBC

Now when a transaction comes through and it goes to write a rule to the database I get this error:

[Jul 25 12:47:41] ERROR[26920]: cdr\_odbc.c:133 odbc\_log: Unable to retrieve database handle. CDR failed.

my res\_odbc.conf looks like:  
[asterisk]  
enabled =\> yes  
dsn =\> asteriskConnector  
username =\> asterisk  
password =\>  
pooling =\> no  
limit =\> 10  
pre-connect =\> yes

and my cdr\_odbc.conf looks like:  
[global]  
dsn=asteriskConnector  
loguniqueid=yes  
username=asterisk  
password=  
dispositionstring=yes  
table=cdr ;“cdr” is default table name  
usegmtime=yes ; set to “yes” to log in GMT

I’ve pretty much run out of ideas of what to look at and try; any direction would be much appreciated.

Cheers,  
Scott

---

<div class="post-metadata">

**Author:** ![scottman](https://avatars.discourse-cdn.com/v4/letter/s/6a8cbe/32.png) [@scottman](https://community.asterisk.org/u/scottman)\
**Post date:** [July 26, 2008, 12:46am UTC](https://community.asterisk.org/t/resolved-cdr-logging-to-postgres-database-problem/22164/2 "2008-07-26T00:46:14Z")

</div>

I found the issue; in 4.6 you need to have the cdr\_odbc.conf file point back to the res\_odbc.conf file entry for the DSN you are trying to hit.
