I'm sure that there are cooler ways to do it, but this one's pretty transparent.my @row; my $select = $dbh->prepare( ' SELECT COUNT(*) FROM games where gamename=? ' ); my $insert = $dbh->prepare( ' INSERT INTO games (gamename, gamedesc, gamecounter) VALUES (?, ?, ?) ' ); my $update = $dbh->prepare( ' UPDATE games SET gamedesc=? where gamename=? ' ); open (FILE, "<../data/games/descriptions.txt") or die $!; while (<FILE>) { chomp; my ($gamename, $gamedesc) = split /\t/; $select->execute($gamename); my $count; while( my $ref = $select-> fetchrow_arrayref() ) { $count = $ref->[0]; } if( $count == 0 ) { #a new game $insert->execute( $gamename, $gamedesc, 0 ); } else { $update->execute( $gamedesc, $gamename ); } } close (FILE);
thor
Feel the white light, the light within
Be your own disciple, fan the sparks of will
For all of us waiting, your kingdom will come
In reply to Re: loading a .txe into a database
by thor
in thread loading a .txe into a database
by Nik
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |