The file above must be inserted to a mysql database automatically. Here is the code.TCPpipe.exe TCPpipe A tool for viewing incoming traffic from rou +ter's forwarded ports! Process.exe Process A tool for viewing WinXP's Processes and it' +s dependencies! StressRelax.exe StressRelax Whip The Worker! Try it, its very fu +nny! Activate.exe Activate A very useful tool for cracking Windows an +d more! GoogleFS.exe GoogleFS A very handy tool to search Google for Fil +es! Speedtouch_Monitor.exe SpeedtouchMon Allows you to view inbound/ +outbound information from router!
The zero in insert statemnt is the counter that will be used later..... $dbh->do( "CREATE TABLE games (file varchar(30) primary key, name text +, description text, counter int)" ); ...... my @row; my $select = $dbh->prepare( 'SELECT COUNT(*) FROM games where name=?' +); my $insert = $dbh->prepare( 'INSERT INTO games (file, name, descriptio +n, counter) VALUES (?, ?, ?, ?)' ); my $update = $dbh->prepare( 'UPDATE games SET description=? where name +=?' ); open (FILE, '<../data/games/descriptions.txt') or die $!; while (<FILE>) { chomp; my ($name, $description) = split /\t/; $select->execute($name); my $count; while( my $ref = $select-> fetchrow_arrayref() ) { $count = $ref->[0]; } if( $count == 0 ) { #a new game $insert->execute( $file, $name, $description, 0 ); } else { $update->execute( $description, $name ); } } close (FILE);
2006-04-17 Retitled by planetscape, as per Monastery guidelines
Original title: 'IHot to insert a tab delimited text file to a mysql database'
In reply to How to insert a tab delimited text file to a mysql database by Nik
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |