in reply to Re^2: DBD::CSV and fetchrow_hashref not working
in thread DBD::CSV and fetchrow_hashref not working
my $dbh = DBI->connect("dbi:CSV:csv_eol=\n;csv_sep_char=\~") or die $D +BI::errstr; $dbh->{'RaiseError'} = 1; $@ = ''; eval { $dbh->{'csv_tables'}->{'JPDObj'} = {'file' => 'data/objectives-cqd +c.txt','col_names' => ["Obj","PosNbr","Year","Div","AVP","Dept","SDes +cr","Major","Methods","Results","Accompl","JanUp","LDescr","Changes", +"Chars","Goals","Budget","CFObj"]}; my $query = "SELECT * FROM JPDObj"; my $sth = $dbh->prepare($query); $sth->execute(); while (my $row = $sth->fetchrow_hashref) { for my $k (keys %$row) { print qq|$k: $row->{$k}\n|; } } }; $@ and die "SQL database error: $@";
|
|---|