Windows, pb avec DBI et DBD::PgPP
voilà, j'ai installé DBI et DBD-PgPP via ppm.
lorsque je lance un script de connection à la base de donnée (PostGres 8.1) voilà l'erreur que j'ai :
Code:
1 2 3 4 5 6
|
E:\dvp>perl gilda.pl
DBD::PgPP::st execute failed: ERROR: syntax error at or near ")" at character 71
Prepare Error: ERROR: syntax error at or near ")" at character 71
E:\dvp> |
Voici mon code :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
#!C:\Perl\bin\perl.exe
use strict;
use Data::Dumper;
use DBI;
use vars qw/
$hostPostgres $portPostgres $userPostgres $passPostgres $database @tables $dbh @tables
/;
$hostPostgres='localhost';
$portPostgres='5432';
$userPostgres='postgres';
$passPostgres='myPass';
$database='ConfigMGT';
@tables=({'name'=>'Test','attribs'=>['id','name','param1','param2'],'nb'=>4},
);
&connectDB();
&executeSql("INSERT INTO Test(id,name,param1,param2) VALUES (0,'nom1','seul param',)");
my $cmd=&executeSql("SELECT DISTINCT * FROM Test ORDER BY name");
while ( my @lines =$cmd -> fetchrow_array) {
my $out="(";
foreach (@lines){
$out.="$_,";
}
chop($out);
$out.=")\n";
print $out;
}
&disconnectDB();
exit 0;
sub connectDB(){
unless(defined $dbh) {
$dbh = DBI->connect(
"dbi:PgPP:dbname=$database;host=$hostPostgres;port=$portPostgres",
$userPostgres, $passPostgres
);
warn "dbh is defined now :p\n";
}
else{
warn "dbh already defined !\n";
}
}
sub executeSql(){
my $req=shift;
&connectDB();
my $cur=$dbh->prepare($req);
$cur->execute();
die "Prepare Error: $DBI::errstr" if $DBI::err;
return $cur;
}
sub disconnectDB(){
$dbh->disconnect() if (defined($dbh));
} |
Comment puis je faire pour réussir à me connecter à une base postgres sous Windows ?
help plz ;)
PS : voici ma version de PgPP :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
|
ppm> install DBD-PgPP
====================
Install 'DBD-PgPP' version 0.05 in ActivePerl 5.8.8.817.
====================
Downloaded 14763 bytes.
Extracting 7/7: blib/arch/auto/DBD/PgPP/.exists
Installing C:\Perl\html\site\lib\DBD\DBD-PgPP.ja.html
Installing C:\Perl\html\site\lib\DBD\PgPP.html
Installing C:\Perl\site\lib\DBD\DBD-PgPP.ja.pod
Installing C:\Perl\site\lib\DBD\PgPP.pm
Successfully installed DBD-PgPP version 0.05 in ActivePerl 5.8.8.817.
ppm> |