3

I am using Perl, and I am able to connect to a local PostgreSQL 9.3 server using this code

#!/usr/bin/perl
use DBI;
use strict;
my $dbh = DBI->connect("dbi:Pg:dbname=postgres;host=127.0.0.1;port=5432", "postgres", "postgres", { RaiseError => 1 }) or die $DBI::errstr;
$dbh->disconnect();
print "Done\n";

Now, following the Catalyst documentation about PostgreSQL I try to generate a Catalyst model.

I use this shell command

script/myapp_create.pl model DB DBIC::Schema MyApp::Schema \
create=static components=TimeStamp,EncodedColumn \
'dbi:Pg:dbname=postgres,host=127.0.0.1,port=5432' 'postgres' 'postgres' '{ AutoCommit => 1 }'

But I get the following error:

DBIx::Class::Storage::DBI::catch {...} (): 
DBI Connection failed: 
DBI connect('dbname=postgres,host=127.0.0.1,port=5432','postgres',...) failed: 
FATAL:  database "postgres,host=127.0.0.1,port=5432" does not exist at 
/usr/local/share/perl/5.18.2/DBIx/Class/Storage/DBI.pm line 1487. at 
/usr/local/share/perl/5.18.2/Catalyst/Helper/Model/DBIC/Schema.pm line 637
Borodin
  • 126,100
  • 9
  • 70
  • 144
Kilátó
  • 403
  • 3
  • 10
  • 19

1 Answers1

5

Your first DBI connection test has a properly configured connection string using semi-colons ';' - your second one is using commas ',' - which are not valid property separators.

Change from;

'dbi:Pg:dbname=postgres,host=127.0.0.1,port=5432'...

To;

'dbi:Pg:dbname=postgres;host=127.0.0.1;port=5432'...
harvey
  • 2,945
  • 9
  • 10
  • 3
    Oh, you are right and correcting them, the command works. This means, I have to change my glasses. At my age ... – Kilátó Oct 28 '14 at 22:22