#!/usr/bin/perl -w
use DBI;

DBI->trace(1);

$db_connection_string = "dbi:Pg:dbname=magnus host=database";
$db = DBI->connect( $db_connection_string, "postgres", "postgres" ) or die "Error";

my $sql = qq|SELECT conkey FROM pg_constraint WHERE contype='p' limit 10|;
my $sth = $db->prepare($sql);
$sth->execute();

while ( $hash_ref = $sth->fetchrow_hashref ) {
  print "Result: ". $hash_ref->{description} ."\n";
}

$sth->finish();
$db->disconnect();
