1if (!defined $ENV{DBI_DSN}) { 2 print "1..0 # Skipped: Cannot run test unless DBI_DSN is defined. See the README file.\n"; 3 exit 0; 4} 5 6use DBI; 7use strict; 8 9print "1..4\n"; 10my $n = 1; 11 12 13my $pgsql; 14eval { 15 $pgsql = DBI->connect($ENV{DBI_DSN}, $ENV{DBI_USER}, $ENV{DBI_PASS}, 16 { RaiseError => 1, PrintError => 0 }); 17}; 18print 'not ' if $@; 19print "ok $n\n"; $n++; 20 21eval { $pgsql->do(q{DROP TABLE test}) }; 22print "not " if $@; 23print "ok $n\n"; $n++; 24 25my $rows = 0; 26eval { 27 my $sth = $pgsql->prepare(q{ 28 SELECT id, name FROM test WHERE id = 1 29 }); 30 $sth->execute; 31 while (my $record = $sth->fetch()) { 32 ++$rows; 33 } 34}; 35print "not " if !defined($@) || $rows > 0; 36print "ok $n\n"; $n++; 37 38eval { $pgsql->disconnect }; 39print 'not ' if $@; 40print "ok $n\n"; 41