]> git.sesse.net Git - ccbs/blobdiff - parse/parse-wiki-songlist.pl
Wrap INSERTs in a transaction.
[ccbs] / parse / parse-wiki-songlist.pl
index 49934c84d4327a005fed9fce9a86d228d1108c19..3f1311839bb9cc2ea88b28584002956e174fa602 100644 (file)
@@ -4,6 +4,8 @@ use warnings;
 
 # Parses songlist from the DDRNO wiki
 
+print "begin;\n";
+
 while (<>) {
        m/
          \|   \s* \[\[ (.*?) \]\] \s*    # song name
@@ -27,8 +29,8 @@ while (<>) {
        $artist =~ s/\[\[//g;
 
        # minimal SQL escaping
-       $songname =~ s/'/\'/g;
-       $artist =~ s/'/\'/g;
+       $songname =~ s/'/\\'/g;
+       $artist =~ s/'/\\'/g;
 
        $maxbpm = $minbpm if (!defined($maxbpm));
        ($maxbpm,$minbpm) = ($minbpm,$maxbpm) if ($maxbpm < $minbpm);
@@ -46,5 +48,6 @@ while (<>) {
                printf "INSERT INTO songratings (song,playmode,difficulty,feetrating) VALUES ((SELECT song FROM songs WHERE title='%s'),'%s','%s',%u);\n",
                        $songname, $t->[0], $t->[1], $t->[2];
        }
-       
 }
+
+printf "commit;\n";