use 5.010;
use strict;
use Data::Dumper;
use DBI;
use Test::More tests => 2;
my $dbh = DBI->connect('dbi:SQLite:database=:memory:')
or die $DBI::errstr;
$dbh->do($_) for
q[CREATE TABLE "Country Info" ("Country Code" CHAR(2) PRIMARY KEY, "Name" VARCHAR(200))],
q[INSERT INTO "Country Info" VALUES ('DE', 'Germany')],
q[INSERT INTO "Country Info" VALUES ('FR', 'France')];
my $sth = $dbh->primary_key_info(undef, undef, "Country Info");
my $row;
ok(
$row = $sth->fetchrow_hashref,
'Found the primary key column.',
);
is(
$row->{COLUMN_NAME},
"Country Code",
'Key column name reported correctly.',
)
or diag Dumper $row;