in reply to Help: column with newlines foils DBD::Anydata?
#!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 |