[Omaha.pm] Another 10 minute DB load hack
Jay Hannah
jhannah at omnihotels.com
Thu Apr 14 15:22:19 PDT 2005
800 lines of Excel spreadsheet into a database in 15 minutes...
j
#!/usr/bin/perl
use Omni::DB;
my $dbh = Omni::DB::connect_prod;
$dbh->do("delete from user_attrib where system = 'CMS'");
my $strsql = "insert into user_attrib values (?, 'CMS', ?, ?)";
my $sth = $dbh->prepare($strsql);
while (<DATA>) {
chomp;
next unless (/\w/);
tr/a-z/A-Z/;
s/ADMINISTRATOR/ADMIN/;
@l = split /\t/;
$l[1] =~ s/\@.*//;
#print "$l[1]|$l[2]|$l[0]|\n";
$sth->execute(@l[1,2,0]);
}
$dbh->commit;
$dbh->disconnect;
__DATA__
Manager bgarlington at nospam.com DALLBJ
User gguyse at nospam.com DALLBJ
User ckreklow at nospam.com DALLBJ
...etc...
More information about the Omaha-pm
mailing list