in reply to DBD::CSV not connecting

DBD::CSV works fine for me with mod_perl. Here's an example script which will print "MAKING NEW CONNECTION..." on the first run and then "RE-USING EXISTING CONNECTION" on all the following runs:

#!/usr/bin/perl -wT use strict; print "Content-type: text/html\n\n"; my $dbh = My::DB->connect(); print "ok!" if $dbh->{RaiseError} == 1 and $dbh->{f_dir} eq '/foo/bar'; package My::DB; use strict; use DBI; sub connect { if (defined $My::DB::conn) { eval {$My::DB::conn->ping}; print "RE-USING EXISTING CONNECTION ...<p>" if !$@; return $My::DB::conn if !$@; } print "MAKING NEW CONNECTION ...<p>"; $My::DB::conn = DBI->connect( 'DBI:CSV(RaiseError=1):f_dir=/foo/bar' ); return $My::DB::conn; } 1;

Note, that it doesn't make any difference if the f_dir directory "/foo/bar" exists - no checking for existence of the f_dir is done at connection time, only when you attempt to access or create a table.

If the script above doesn't work for you, make sure that you are using the latest versions of DBD::CSV and DBD::File (which is found in the latest distribution of DBI).

Replies are listed 'Best First'.
Re^2: DBD::CSV not connecting
by earl_the_perl (Novice) on Sep 27, 2004 at 18:59 UTC
    Thank you jZed. I took your connect statement directly and still encountered the same error. The dbitrace was still hanging on the statement

    -> DBI->install_driver(CSV) for dynixptx perl=5.006001 pid=25729 ruid=50195 euid=50195

    I then did a find for the CSV.pm file itself inside the DBD folder and it wasn't there. The module management is not very good here and they are challenged managing modules built for a variety flavors of Solaris, Sequent and Windows. Modules that exist in some environments are missing in others. That's were the fun begins!!

    I would expect DBD to error out when it cannot find the CSV.pm file though, wouldn't you?
    Thanks ETP
      If I rename ...site/lib/DBD/CSV.pm, the script above does error out with "install_driver(CSV) failed: Can't locate DBD/CSV.pm in @INC..." as it should. If you're not getting that error message, then perhaps you have a CSV.pm somewhere else in your @INC, or else you haven't turned RaiseError on for the connect, or have some other bug in your error reporting strategy.