我正在使用Perl,我可以使用连接到本地PostgreSQL 9.3服务器 这段代码
#!/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";
现在,在Catalyst documentation about PostgreSQL之后,我尝试生成Catalyst模型。
我使用这个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
答案 0 :(得分:4)
您的第一个DBI连接测试使用分号“;”正确配置了连接字符串 - 你的第二个使用逗号',' - 它们不是有效的属性分隔符。
改变自己;
'dbi:Pg:dbname=postgres,host=127.0.0.1,port=5432'...
要;
'dbi:Pg:dbname=postgres;host=127.0.0.1;port=5432'...