2014-10-28 8 views
2

펄을 사용하고, 나는 내가 촉매를 생성하려고 Catalyst documentation about PostgreSQL 다음, 이제 이 코드 펄 DBI 연결 작동하지만 촉매

#!/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"; 
를 사용하여 로컬 PostgreSQL의 9.3 서버에 연결할 수 있어요 모델.

나는이 쉘 명령을 사용

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 }' 

하지만 다음과 같은 오류가 발생합니다 :

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 

답변

4

첫 번째 DBI 연결 테스트가 세미콜론을 사용하여 제대로 구성 연결 문자열을 가지고 ';' - 두 번째는 쉼표 ','를 사용하고 있습니다. 이는 유효한 속성 구분 기호가 아닙니다.

변경 사항;

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

To;

'dbi:Pg:dbname=postgres;host=127.0.0.1;port=5432'... 
+3

오, 당신 말이 맞아요. 명령이 제대로 작동합니다. 이것은 내 안경을 바꾸어야한다는 것을 의미합니다. 내 나이에 ... –