todd has asked for the wisdom of the Perl Monks concerning the following question:
Hello Monks,
I'm having a problem using DBI:CSV.
Assuming the existence of a file ./test_db which looks like
f1,f2,f3,f4,f5
Can someone explain to me why the following code works
#!/usr/bin/perl
use DBI;
my $dbh = DBI->connect("DBI:CSV:")
or die "Can't connect: " . $DBI::errstr;
my @fields = qw(one two three four five);
$dbh->do("INSERT INTO test_db VALUES(?,?,?,?,?)",undef,one, two, three, four, five);
$dbh->disconnect;
## End code
Yet the following doesn't
#!/usr/bin/perl
use DBI;
my $dbh = DBI->connect("DBI:CSV:")
or die "Can't connect: " . $DBI::errstr;
my @fields = qw(one two three four five);
my $sql=qq`"INSERT INTO test_db VALUES (?,?,?,?,?)"` . ",undef," . join( ',' ,@fields);
$dbh->do($sql);
$dbh->disconnect;
## End code
This fails with the error
DBD::CSV::db do failed: Parse error near "INSERT INTO test_db VALUES (?,?,?,?,?)",undef,one,two,three,four,five at /usr/lib/perl5/site_perl/5.005/DBD/File.pm line 164.
Thank you in advance.
Todd
</body>
</html>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: DBI:CSV problem
by chromatic (Archbishop) on Sep 20, 2000 at 22:37 UTC | |
|
RE: DBI:CSV problem
by little (Curate) on Sep 20, 2000 at 15:56 UTC | |
|
Re: DBI:CSV problem
by Anonymous Monk on Sep 20, 2000 at 16:37 UTC |