• Publicidad

Problemas con Perl y Postgres

¿Apenas comienzas con Perl? En este foro podrás encontrar y hacer preguntas básicas de Perl con respuestas aptas a tu nivel.

Problemas con Perl y Postgres

Notapor thegame » 2012-02-29 11:16 @511

Tengo el siguiente código:

Sintáxis: [ Descargar ] [ Ocultar ]
Using perl Syntax Highlighting
  1. #!/usr/bin/perl
  2. use CGI;
  3. use DBI;
  4. use DBD::Pg;
  5.  
  6. #use CGI::Carp qw(fatalsToBrowser);
  7. #print error;
  8. #print "Content-type: text/html;charset=UTF-8\n\n";
  9.  
  10. my $dbh = DBI->connect( "DBI:Pg:dbname=pruebaconex;host=localhost;port=5432",
  11.     "directorio", "directorio", { pg_enable_utf8 => 1 } )
  12.     or die "Unable to connect: $DBI::errstr\n";
  13. my $sth = $dbh->prepare("SELECT columna,columna1 FROM tabla");
  14. $sth->execute();
  15. while ( @row = $sth->fetchrow_array ) { push( @row1, $row[0] ) }
  16.  
  17. #print "en el modulo:@row";
  18. $sth = $dbh->disconnect();
  19. print "aki esta el:@row1";
  20.  
Coloreado en 0.003 segundos, usando GeSHi 1.0.8.4



y m arroja el siguiente error cuando lo ejecuto:


Sintáxis: [ Descargar ] [ Ocultar ]
Using bash Syntax Highlighting
  1. DBI connect('dbname=pruebaconex;host=10.16.105.174;port=5432','directorio',...) failed: no se pudo conectar con el servidor: Expiró el tiempo de conexión
  2.         ¿Está el servidor en ejecución en el servidor «10.16.105.174» y aceptando
  3.         conexiones TCP/IP en el puerto 5432? at prueba.pl line 12
  4. Unable to connect: no se pudo conectar con el servidor: Expiró el tiempo de conexión
  5.         ¿Está el servidor en ejecución en el servidor «10.16.105.174» y aceptando
  6.         conexiones TCP/IP en el puerto 5432?
Coloreado en 0.004 segundos, usando GeSHi 1.0.8.4



En el postgresql.conf está el puerto 5432 y están escuchando todas las peticiones ('*').
En el pg_hba está configurado así:

Sintáxis: [ Descargar ] [ Ocultar ]
Using text Syntax Highlighting
  1. # "local" is for Unix domain socket connections only
  2. local   all         all                               md5
  3. # IPv4 local connections:
  4. host    all         all         127.0.0.1/32          md5
  5. host    all         all         0.0.0.0/0             md5
  6. # IPv6 local connections:
  7. host    all         all         ::1/128               md5
Coloreado en 0.000 segundos, usando GeSHi 1.0.8.4


y el postgresql.conf
Sintáxis: [ Descargar ] [ Ocultar ]
Using text Syntax Highlighting
  1. # CONNECTIONS AND AUTHENTICATION
  2. #------------------------------------------------------------------------------
  3.  
  4. # - Connection Settings -
  5.  
  6. listen_addresses = '*'          # what IP address(es) to listen on;
  7.                                         # comma-separated list of addresses;
  8.                                         # defaults to 'localhost', '*' = all
  9.                                         # (change requires restart)
  10. port = 5432                             # (change requires restart)
  11. max_connections = 100  
Coloreado en 0.000 segundos, usando GeSHi 1.0.8.4


- el servicio está arriba (estoy usando Debian)
- puedo entrar por psql y trabajar en la base de datos tranquilamente
- me conecto por pgadmin desde otra máquina remotamente y se conectó normalmente
- en la conexión probé host=127.0.0.1, y nada

Entonces, ¿qué podrá ser? Ya no tengo idea...
thegame
Perlero nuevo
Perlero nuevo
 
Mensajes: 38
Registrado: 2011-11-08 11:19 @513
Ubicación: Venezuela

Publicidad

Re: Problemas con Perl y PostgreSQL

Notapor irving » 2012-02-29 16:17 @720

¿Qué versión de postgreSQL estás usando?

Si es menor de la 7.2 intenta usar password en reemplazo de MD5 para la autorización.

El usuario por defecto es postgres.
Búscame en twitter
Avatar de Usuario
irving
Perlero nuevo
Perlero nuevo
 
Mensajes: 10
Registrado: 2012-02-23 16:01 @709
Ubicación: Chiclayo, Lambayeque, Perú

Re: Problemas con Perl y Postgres

Notapor thegame » 2012-02-29 16:21 @723

¡8.4, amigo!
thegame
Perlero nuevo
Perlero nuevo
 
Mensajes: 38
Registrado: 2011-11-08 11:19 @513
Ubicación: Venezuela

Re: Problemas con Perl y Postgres

Notapor pvaldes » 2012-02-29 21:25 @934

(cómo odio cuando veo escrito "aki" en un foro :| )

No le voy a dedicar mucho más tiempo a tu problema, pero probablemente quieras revisar la línea 18, de todos modos.
pvaldes
Perlero nuevo
Perlero nuevo
 
Mensajes: 129
Registrado: 2011-01-22 12:56 @580


Volver a Básico

¿Quién está conectado?

Usuarios navegando por este Foro: No hay usuarios registrados visitando el Foro y 50 invitados

cron