#!/usr/bin/perl # db2mysql.pl - read the tab-delimited file and ingest into mysql # Eric Lease Morgan # February 13, 2011 - first cut # configure use constant DB => './irclog.db'; use constant DSN => 'dbi:mysql:c4l11'; use constant PASSWORD => '-------'; use constant USERNAME => '-------'; # require use DBI; use strict; # initialize my $dbh = DBI->connect( DSN, USERNAME, PASSWORD ); # loop through db file open INPUT, ' < ' . DB or die "Can't open " . DB . ": $!\n"; while ( ) { # clean, parse, and build corpus chop; my ( $datestamp, $name, $text ) = split /\t/, $_; # insert $dbh->do( 'INSERT INTO `irc` ( `datetime`, `author_id`, `irc` ) VALUES ( ?, ?, ? )', undef, $datestamp, $name, $text ); } # done close INPUT; exit;