in reply to Re: Trouble getting DBD::CSV to work
in thread Trouble getting DBD::CSV to work

I've tried:
my $dbh = DBI->connect ("dbi:CSV:f_dir=/root", undef, undef, { f_ext => ".csv", RaiseError => 1, } );
and
my $dbh = DBI->connect ("dbi:CSV:f_dir=root", undef, undef, { f_ext => ".csv", RaiseError => 1, } );
and
my $dbh = DBI->connect ("dbi:CSV:", undef, undef, { f_ext => ".csv", RaiseError => 1, f_dir => "/root", } );
and:
my $dbh = DBI->connect ("dbi:CSV:", undef, undef, { f_ext => ".csv", RaiseError => 1, f_dir => "root", } );
But none of these work. Can you please clarify what you meant?

Replies are listed 'Best First'.
Re^3: Trouble getting DBD::CSV to work
by Tux (Canon) on Aug 05, 2014 at 08:29 UTC

    Your original post said "dbi:CSV:f_dir:/root, which was obviously wrong, and thus most likely the cause of failure.

    Assuming you have recent enough versions of the modules you use, what is the output of:

    use strict; use warnings; use DBI; my $dbh = DBI->connect ("dbi:CSV:", undef, undef, { f_dir => "/root", f_ext => ".csv/r", RaiseError => 1, PrintError => 1, ShowErrorStatement => 1, }); print "DBI-$DBI::VERSION\n"; print "DBD::CSV-$DBD::CSV::VERSION\n"; print "Text::CSV_XS-$Text::CSV_XS::VERSION\n"; print "SQL::Statement-$SQL::Statement::VERSION\n"; print "\n"; print "$_\n" for $dbh->tables (undef, undef, undef, undef);

    Enjoy, Have FUN! H.Merijn
      DBI-1.609 DBD::CSV-0.22 Text::CSV_XS-0.85 SQL::Statement-1.27 "root".export "root".export3 "root".export2

        A lot has changed since DBD-CSV-0.22! That version was from April 2005.

        At the moment of writing, the current versions are:

        DBI-1.631 DBD::CSV-0.44 Text::CSV_XS-1.10 SQL::Statement-1.405

        My first hunch would be, with your old versions, to add the schema:

        my $sth = $dbh->prepare (q{select * from "root".export}); $sth->execute; while (my $h = $dbh->fetchrow_hashref) { # Don't know if casing of fieldnames is sane in those versions # YMMV, $dbh->{FetchHashKeyName} = "NAME_lc"; might help print "ID: ", $h->{id}, ", SN: ", $h->{service_name}; }

        Enjoy, Have FUN! H.Merijn