in reply to DBI insert: Need to store results in a MySQL-database (not in a file)
I see you've collected your data into %school. Using that as your data source, you'll need something like the following.
Do these once:
use DBI; my $dbh = DBI->connect(...); my $sql_insert = q{ insert into school_tbl (location, name, type, address, description) values (?, ?, ?, ?, ?) }; my $sth = $dbh->prepare($sql_insert);
For each iteration through your data:
$sth->execute(@school{qw{location name type address description}});
And finally, do these once:
$sth->finish(); $dbh->disconnect();
NOTE: This code is completely untested and includes no error checking.
All of the above methods are documented in DBI.
-- Ken
|
|---|