in reply to Re: DBD::CSV and fetchrow_hashref not working
in thread DBD::CSV and fetchrow_hashref not working

Thank you for your reply. I still cannot get it to work despite trying the code. Perhaps it is a server setting. It's like it doesn't fetch at all.

And, yes, in the full code, I am actually doing something to output the results.

-Jacvivs

  • Comment on Re^2: DBD::CSV and fetchrow_hashref not working

Replies are listed 'Best First'.
Re^3: DBD::CSV and fetchrow_hashref not working
by tangent (Parson) on Dec 11, 2013 at 21:13 UTC
    Maybe you should test the connection and other workings first, something like:
    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: $@";