<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
  <META NAME="GENERATOR" CONTENT="GtkHTML/3.32.2">
</HEAD>
<BODY>
Thank you Jonathan,<BR>
<BR>
I already do the steps you mention, my configuration is:<BR>
<BR>
in res_odbc.conf<BR>
<BR>
enabled =&gt; yes<BR>
dsn =&gt; asterisk-connector<BR>
pre-connect =&gt; yes<BR>
<BR>
in odbc.ini<BR>
<BR>
[asterisk-connector]<BR>
Description&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = PostgreSQL connection to 'asterisk' database<BR>
Driver&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = PostgreSQL<BR>
Database&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = db_asterisk<BR>
Servername&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = localhost<BR>
UserName&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = asterisk<BR>
Password&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = secret<BR>
Port&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = 5432<BR>
Protocol&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = 9.1<BR>
ReadOnly&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = No<BR>
RowVersioning&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = No<BR>
ShowSystemTables&nbsp;&nbsp;&nbsp; = No<BR>
ShowOidColumn&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = No<BR>
FakeOidIndex&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = No<BR>
ConnSettings&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =<BR>
<BR>
<BR>
in odbcinst.ini<BR>
<BR>
[PostgreSQL]<BR>
Description&nbsp;&nbsp;&nbsp;&nbsp; = ODBC for PostgreSQL<BR>
Driver&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = /usr/lib/libodbcpsql.so<BR>
Setup&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = /usr/lib/libodbcpsql.so<BR>
FileUsage&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = 1<BR>
<BR>
if I run with root:<BR>
<BR>
#echo &quot;select 1&quot; | isql -v asterisk-connector<BR>
<BR>
returns <BR>
<BR>
+---------------------------------------+<BR>
| Connected!&nbsp;&nb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nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<BR>
+---------------------------------------+<BR>
SQL&gt; select 1<BR>
+------------+<BR>
| ?column?&nbsp;&nbsp; |<BR>
+------------+<BR>
| 1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<BR>
+------------+<BR>
SQLRowCount returns 1<BR>
1 rows fetched<BR>
<BR>
This show me that it can connect, the thing is that in the asterisk logs it returns:<BR>
<BR>
res_odbc.c: Connecting asterisk<BR>
res_odbc.c: res_odbc: Error SQLConnect=-1 errno=101 [unixODBC]Could not connect to the server;<BR>
Could not connect to remote socket<BR>
res_odbc.c: Failed to connect to asterisk<BR>
res_odbc.c: Registered ODBC class 'asterisk' dsn-&gt;[asterisk-connector]<BR>
res_odbc.c: res_odbc loaded.<BR>
<BR>
I notice that if I run the isql command with other user than root, it returns <BR>
<BR>
[S1000][unixODBC]Could not connect to the server;<BR>
Could not connect to remote socket.<BR>
[ISQL]ERROR: Could not SQLConnect<BR>
<BR>
I guess is an extra configuration for ODBC that I am missing, what you think?<BR>
<BR>
Regards,<BR>
<BR>
On Fri, 2012-02-24 at 13:16 -0600, Jonathan Rose wrote: 
<BLOCKQUOTE TYPE=CITE>
<PRE>
You need to make sure ODBC is actually getting a connection made with your database.

What you should see under ODBC DSN settings:

  Name:   asterisk
  DSN:    asterisk-connector
    Last connection attempt: WHATEVER
  Pooled: No/Yes
  Connected: Yes

Connected: Yes is the important part.

Remember, you need to have an account in postgres that can be logged into.  I made one on my machine with the following:

name = asterisk
password = secret

And in /etc/odbc.ini, I have the following connector established:
[asterisk-connector]
Description         = PostgreSQL connection to 'asterisk' database
Driver              = PostgreSQL
Database            = asterisk
Servername          = localhost
UserName            = asterisk
Password            = secret
Port                = 5432
Protocol            = 8.1   &lt;I'm guessing this will be 9.1 in your case&gt;
ReadOnly            = No
RowVersioning       = No
ShowSystemTables    = No
ShowOidColumn       = No
FakeOidIndex        = No
ConnSettings        =

While my res_odbc.conf looks like this:

[asterisk]
enabled =&gt; yes
dsn =&gt; asterisk
pre-connect =&gt; yes

In addition to having a connector defined, you need to have an ODBC adapter for postgres.  I think this might come with ODBC byd efault though.  When I was using mysql, I had to get a separate adapter to make it work and set the path to it in Driver.  I don't think that is the case with pgsql though.

Go ahead and post your extconfig.conf.  I'm guessing that the reason you are able to post CDRs in spite of not having the Connected status show up in your ODBC show is because you are connecting with res_pgsql.conf instead of odbc.


----- Original Message -----
From: &quot;Sergio Basurto&quot; &lt;<A HREF="mailto:sbasurto@soft-gator.com">sbasurto@soft-gator.com</A>&gt;
To: <A HREF="mailto:asterisk-users@lists.digium.com">asterisk-users@lists.digium.com</A>
Sent: Wednesday, February 22, 2012 6:54:47 AM
Subject: Re: [asterisk-users] Postgresql in Asterisk


On Wed, 2012-02-22 at 06:48 -0600, Sergio Basurto wrote: 


Hello, 

I install asterisk an postgresql 9.1 in gentoo, I already did the configuration in both asterisk and postgresql, in fact If I make a call and asterisk log it to CDR table, my question is: 
I make a typo mistake I mean If I make a call asterisk already log it into CDR table. 



how can I make a function like the ones in func_odbc.conf for postgresql, if I am using res_pgsql.conf instead of res_odbc.conf? 

I also configure odbc and it connects with echo &quot;select 1&quot; | isql -v asterisk-connector with out problems, but when I try an odbc function or restart asterisk it logs: 

Error SQLConnect=-1 errno=101 [unixODBC]Could not connect to the server; Could not connect to remote socket. 

and the command 

CLI&gt; odbc show 

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

Name: asterisk 
DSN: asterisk-connector 
Last connection attempt: 2012-02-22 06:45:36 


I will appreciate any help. 


Regards, 

--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by <A HREF="http://www.api-digital.com">http://www.api-digital.com</A> --
New to Asterisk? Join us for a live introductory webinar every Thurs: <A HREF="http://www.asterisk.org/hello">http://www.asterisk.org/hello</A> asterisk-users mailing list
To UNSUBSCRIBE or update options visit: <A HREF="http://lists.digium.com/mailman/listinfo/asterisk-users">http://lists.digium.com/mailman/listinfo/asterisk-users</A> 
        -- 
Sergio Basurto &lt; <A HREF="mailto:sbasurto@soft-gator.com">sbasurto@soft-gator.com</A> &gt; 
Soft Gator S.A de C.V. 
--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by <A HREF="http://www.api-digital.com">http://www.api-digital.com</A> --
New to Asterisk? Join us for a live introductory webinar every Thurs:
               <A HREF="http://www.asterisk.org/hello">http://www.asterisk.org/hello</A>

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   <A HREF="http://lists.digium.com/mailman/listinfo/asterisk-users">http://lists.digium.com/mailman/listinfo/asterisk-users</A>
</PRE>
</BLOCKQUOTE>
<BR>
<TABLE CELLSPACING="0" CELLPADDING="0" WIDTH="100%">
<TR>
<TD>
-- <BR>
Sergio Basurto &lt;<A HREF="mailto:sbasurto@soft-gator.com">sbasurto@soft-gator.com</A>&gt;<BR>
Soft Gator S.A de C.V.
</TD>
</TR>
</TABLE>
<BR>
</BODY>
</HTML>