http://qs321.pair.com?node_id=455572


in reply to Updating or Inserting a database from a txt file

Usless post: read at your own risk.

I should have know this node would get up-voted and front-paged...

Noone cares that this is the third time that the OP asks the same question, right?

Even when in the previous nodes working code (and good code) was suggested, clearly the OP decides not to use it and use yet another approach... Why is the biggest question I guess...

  • Comment on Re: Updating or Inserting a database from a txt file

Replies are listed 'Best First'.
Re^2: Updating or Inserting a database from a txt file
by DaWolf (Curate) on May 10, 2005 at 15:11 UTC
    Actually the OP's previous posts seem different from this one. Previously he was looking for answers and now he's looking for improvements.

    Have I missed something?

    Nik, please be polite. Rudeness will only make things worse.

    Hope you find your answers.

    Regards,
      Sorry man, i got carried away there but i become mad with the both of them and especially Animator on irc.
      Yes iam trying to improve the script as you correctly noticed.

      I changed it again. Here it is now:
      my (@row, $gamename, $gamedesc, $gamecount); my $select = $dbh->prepare( "SELECT * FROM games WHERE gamename=$gamen +ame" ); my $insert = $dbh->prepare( "INSERT INTO games (gamename, gamedesc, ga +mecounter) VALUES (?, ?, ?)" ); my $update = $dbh->prepare( "UPDATE games SET gamedesc=?, gamecount=?+ +1 where gamename=?" ); open (FILE, "<../data/games/descriptions.txt") or die $!; while (<FILE>) { chomp; ($gamename, $gamedesc) = split /\t/; $select->execute( $gamename ); if ($select->rows) { $update->execute( $gamedesc, $gamecount, $gamename ); } else { $insert->execute( $gamename, $gamedesc, 0 ); } } close (FILE);
      the descriptions.txt contains a blank line after each line of info. I dont want it to be loaded and also every time games.pl is runnign it gets doubled and doubles each time!

      Anyone can see why?
Re^2: Updating or Inserting a database from a txt file
by mlh2003 (Scribe) on May 10, 2005 at 14:00 UTC
    I didn't see the previous post :(
    Otherwise I probably would have said something similar...
    _______
    Code is untested unless explicitly stated
    mlh2003
A reply falls below the community's threshold of quality. You may see it by logging in.
A reply falls below the community's threshold of quality. You may see it by logging in.