Jeff,
        I'm adding more support for csv in DBI::Shell.  However, I'm 
seeing some odd results.

If I use this connection string and query.  0 Rows are fetched.
(some code removed for brevity)

        my $dbh = DBI->connect("DBI:CSV:f_dir=.")
        ...

        my $sth = $dbh->prepare("select * from myfile")
        ...

        $sth->execute() ...
        my $count = 0;
        while (my $row = $sth->fetchrow_arrayref) {
                print join "|", @$row, "\n";
                $count++;
        }
        warn  "Fetched $count rows\n";

Where as this return rows 3 of 4 rows (first row is consumed for column
names?)
        my $dbh = DBI->connect("DBI:CSV:f_dir=.;csv_eol=\n")
        ...

The default behavior (from the docs) looks carriage return, line feed.
        csv_csv The attributes csv_eol ... Defaults are "\015\012"

Would it be more portable if the default eol be based on the OS eol?

Tom

Perl            : 5.008 (i386-linux-thread-multi)
OS              : linux (2.4.20-2.48smp)
DBI             : 1.38
DBD::mysql      : 2.1021
DBD::Sponge     : 11.09
DBD::Proxy      : 0.2004
DBD::Pg         : 1.31_3
DBD::Oracle     : 1.14
DBD::Multiplex  : 0.9
DBD::File       : 0.2001
DBD::ExampleP   : 11.10
DBD::CSV        : 0.2002

SQL::Statement  : 1.005

File: out.pl
#!/usr/bin/perl

use strict;
use warnings;

use DBI;

# Returns 0 rows.
# my $dbh = DBI->connect("DBI:CSV:f_dir=.")

# Works, except skips the first line (fields names)
my $dbh = DBI->connect("DBI:CSV:f_dir=.;csv_eol=\n")
        or die "Cannot connect: " . $DBI::errstr;

$dbh->{RaiseError} = 1; $dbh->{PrintError} = 1;

my $sth = $dbh->prepare("select * from myfile")
        or die "Cannot prepare: " . $dbh->errstr();

$sth->execute() or die "Cannot execute: " . $sth->errstr();

my $count = 0;
while (my $row = $sth->fetchrow_arrayref) {
        print join "|", @$row, "\n";
        $count++;
}

warn  "Fetched $count rows\n";
$sth->finish();

$dbh->disconnect();

exit;

__END__
Contents of myfile
1,Tom
2,Aaron
3,Ryan
4,Susan

Reply via email to