2014-10-28 69 views
2

我使用Perl和我能够连接到使用 此代码Perl的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服务器,继Catalyst documentation about PostgreSQL我尝试生成催化剂模型。

我用这个shell命令

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

要;

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

哦,你说得对,纠正他们,命令的作品。这意味着,我必须更换眼镜。在我这个年纪... – 2014-10-28 22:22:46