Gregg O'Donnell wrote at Fri, 09 Aug 2002 20:32:38 +0200:

> Hey - I'm trying to put this together from studying the perldoc. Do I need to define 
>"my $table =" and if so, to the csv file? Also, the number of scalars should equal 
>the number of question marks?
> 
> use DBI;
> 
> my $dbh = DBI->connect(qq{DBI:CSV:csv_sep_char=\\;});
> my $dbh->{'csv_tables'}->{'logger'} = { 'file' => 'logger.csv'};
> my $sth = $dbh->do("INSERT INTO $table VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", 
>undef, $name_logger, $phone_logger, $email_logger, $name_landowner, $phone_landowner, 
>$county, $logging_location, $logging_begin, $acres, $conf_number); 
> 
> my $sth->execute() or die "Cannot execute: " . $sth->errstr();
> my $sth->finish();
> my $dbh->disconnect();

If you only want to add one row to CSV file,
perhaps an other module is more convenient:

tie my @data, 'Tie::CSV_File', 'logger.csv', sep_char => ';';
push @data, [undef, $name_logger, $phone_logger, $email_logger, 
             $name_landowner, $phone_landowner, $county, $logging_location, 
             $logging_begin, $acres, $conf_number];
 

But of course,
if you need SELECT or a similar statement,
DBI::CSV is quite more simple


Best Wishes,
Janek

PS: Please excuse this announce, as I wrote that module :D


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to