in reply to Help: column with newlines foils DBD::Anydata?

The next version of DBD:AnyData will support embedded newlines. For now you can use DBD::CSV instead which uses the same SQL engine as DBD::AnyData and already supports embedded newlines and works fine with tab. Another option is to stick with DBD::AnyData but redefine the eol (end of line) to something other than "\n". For example, on windows, this script creates an queries a tab-separated file containing fields with embedded newlines:
#!perl -w use strict; use DBI; my $dbh=DBI->connect('dbi:AnyData(RaiseError=1):'); $dbh->ad_catalog( 'test' , 'CSV' , 'newline.csv' , {sep_char=>"\t",eol=>"\015"} ); my %sql = ( drop => 'DROP TABLE test' , create => 'CREATE TABLE test (id INT, phrase VARCHAR(30))' , insert => 'INSERT INTO test VALUES(?,?)' , query => 'SELECT * FROM test' ); my $insert = $dbh->prepare( $sql{insert} ); my $query = $dbh->prepare( $sql{query} ); eval { $dbh->do( $sql{drop} ) }; $dbh->do( $sql{create} ); $insert->execute(1,"foo\n\nbar"); $insert->execute(2,'baz'); $query->execute; while (my $row=$query->fetch) { print "[$_] " for @$row; print "~\n"; }

Replies are listed 'Best First'.
Re^2: Help: column with newlines foils DBD::Anydata?
by McMahon (Chaplain) on Jun 30, 2004 at 18:11 UTC
    Thanks jZed, DBD::CSV vs. a tab-separated file worked just fine.