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).


In reply to Re: DBD::CSV not connecting by jZed
in thread DBD::CSV not connecting by earl_the_perl

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.