in reply to DBD::CSV not connecting
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.#!/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;
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 | |
by jZed (Prior) on Sep 27, 2004 at 19:41 UTC |