【问题标题】:Perl DBI connection works but not with CatalystPerl DBI 连接有效,但不适用于 Catalyst
【发布时间】:2014-12-24 12:17:50
【问题描述】:

我正在使用 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

【问题讨论】:

    标签: perl dbi catalyst postgresql-9.3


    【解决方案1】:

    您的第一个 DBI 连接测试使用分号“;”正确配置了连接字符串- 您的第二个使用逗号 ',' - 这不是有效的属性分隔符。

    变化自;

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

    到;

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

    【讨论】:

    • 哦,你是对的,纠正他们,命令有效。这意味着,我必须更换我的眼镜。在我这个年纪...
    猜你喜欢
    • 2013-03-25
    • 2015-09-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-02
    • 1970-01-01
    相关资源
    最近更新 更多