i've tried and failed many times to get Class::DBI to work with a CSV file by using the DBD::AnyData driver. i finally tracked down the solution to the last error:

Can't locate object method "select_row" via package "DBI::st" at /usr/ +lib/perl5/site_perl/5.8.2/Class/DBI.pm line 780.

seems the DBIx::ContectualFetch module provides the needed function.

package TableName; use base 'Class::DBI'; my $dbh = DBI->connect( "dbi:AnyData:", undef, undef, { RootClass => 'DBIx::ContextualFetch', ShowErrorStatement => 1, RaiseError => 1, AutoCommit => 1, PrintError => 1, Taint => 1, FetchHashKeyName => '"NAME_lc"', ChopBlanks => 1, }); $dbh->func( 'tablename', 'CSV', 'filename.csv', { field_sep => q(\\^) +}, 'ad_catalog'); # this instead of __PACKAGE__->set_db( ... ) sub db_Main { return $dbh; } __PACKAGE__->table( 'tablename' ); __PACKAGE__->columns( All => qw/ ip sysDescr / ); 1;

with that last bit Class::DBI seems to play nicely with CSV files.

edit (broquaint): changed <pre> tags around error message to <code> tags

Replies are listed 'Best First'.
Re: Class::DBI with DBD::AnyData
by jZed (Prior) on May 19, 2004 at 03:30 UTC
    Actually the problem is with improper setting of the Active in all the modules which subclass DBD::File (CSV,AnyData, etc). I've fixed it in releases that are almost ready. I also have created a Class::DBI::AnyData/CSV/DBM and Class::DBI::Loader::AnyData/CSV/DBM modules almost ready. If you can't wait until I've tested and released, let me know and I'll send you development versions to play with.