in reply to Re: DBD::CSV and long fields (LongReadLen not supported?)
in thread DBD::CSV and long fields (LongReadLen not supported?)

absolutely: here is the first 10 lines of text: http://pastebin.com/R8E6jVhs

Here is the code:

#! c:\program files\perl\bin use DBI; my $csv="viewmanifest.csv"; $dbh=DBI->connect('DBI:CSV:$csv') or die "Can't Connect"; $sth=$dbh->prepare("SELECT RowId, dahandle, darelativepath, dafilestat +e, dafilestatetime, dafilesource, fileguid, size, filemd5, child, chi +ldtype, childhandle, container, containerfolder, maghandle, mailconta +inererror, mailcontainer, mailfolder, mailfolderpath, contentmd5, cre +atedtime, datescanned, embeddedchildren, docclass, handle, docnum, os +folder, filename, docext, origdocext, filemode, fullpath, filetype, a +uxfiletype, lastaccesstime, lastmodifiedtime, lastchangetime, mimetyp +e, kftdesc, ocrpath, ocrstatus, ownergroup, owneruser, acls, parent, +parsingstatus, parserversion, altbody, importpath, importdevice, impo +rtarea, ancestordahandle, depotfile, inode, batch FROM $csv") or die +"Can't prepare"; $sth->execute(); $sth->dump_results(); $sth->finish(); $dbh->disconnect();

Here are the results for the first line (notice the ellipses)

'0', '000083e0143381bbe8db4b0db7baa5...', 'vmi/v920m3/weekly.20091014/pro...', 'imported', '2011-04-15-21-00-51', '000083e0143381bbe8db4b0db7baa5...', '', '0000000000000063906', 'a088be10e6f02f614385fa19628cfb6f', '', '', '', '', '', '', '', '', '', '', '', '', '2011-04-15-21-00-51', '', 'loose', 'a088be10e6f02f614385fa19628cfb...', '', 'vmi/v920m3/weekly.20091014/pro...', 'en_X11.xml', 'xml', '', '33188', '', 'extensible markup language (xml)', '', '2009-10-15-19-15-34', '2009-10-15-19-15-49', '2009-10-15-19-15-49', '', '', '', '', '100', '13936', '', '', '00000 SUCCESS', '3.4;3.4', '', '000083e0143381bbe8db4b0db7baa5...', '', '', '', '', '32457187', 'f8023f8fc92a4fc4'

Other things of note, could have unicode filenames...

Replies are listed 'Best First'.
Re^3: DBD::CSV and long fields (LongReadLen not supported?)
by Tux (Canon) on Apr 27, 2011 at 14:51 UTC

    dump_results is not meant to fetch data!

    use strict; use warnings; use autodie; use DBI; use Data::Peek; # For debugging only my $dbh = DBI->connect ("dbi:CSV:", undef, undef, { f_dir => ".", f_ext => ".csv/r", RaiseError => 1, PrintError => 1, }); my $sth = $dbh->prepare ("select * from viewmanifest"); my %rec; $sth->execute; $sth->bind_columns (\@rec{@{$sth->{NAME_lc}}}); while ($sth->fetch) { DDumper \%rec; # For debugging only print $rec{dahandle}, "\n"; } $dbh->disconnect;

    FWIW DBD::CSV doesn't need to support LongReadLen as the only limit to the size of the fields is implied by the available memory and the remaining space on disk (DBD::CSV is always AutoCommit so the data in the table should also fit on disk). The other database that I know of that ignores LongReadLen completely as it has direct bindings to the perl variable is DBD::Unify.


    Enjoy, Have FUN! H.Merijn
      Wow. Thanks very much for that. If I could ask a couple of questions:

      1. I can't seem to find data::peek in ActivePerl's package manager... I realize it isn't necessary, but I would like to see what it does.

      2. I am unclear what exactly the line "$sth->bind_columns (\@rec{@{$sth->{NAME_lc}}});" does... could you give me a little more detail here? I realize it is selecting the column to print, but the syntax is more complicated than I am used to

      Again thanks for your help. I am a bit of a neophyte and I don't understand binding columns quite yet.

        Data::Peek is a bit like Data::Dumper, just offering a bit more direct entries to perl's internal debugging functions. I wrote it, so it is effectively a shameless plug. However, I also use it very very often, and it has turned out to be my fav debugging tool. As some symbols needed to get the complete set of features might not be available on ActivePerl (due to linking differences on Windows), that might be why ActiveState does not include it in their binary ppm packages.

        The bind_columns example (third code snippet) is almost literally part of the DBI documentation. It is not selecting columns to print, but setting the destination for the fetched fields.


        Enjoy, Have FUN! H.Merijn