Playlist support, other randomness.
[dvddb] / upgrade-v2
index 1846791..f998f3c 100755 (executable)
@@ -10,12 +10,13 @@ BEGIN { binmode STDOUT, ":utf8"; }
 my $DB = DBI->connect("dbi:Pg:host=roadstar", "", "",
                      { AutoCommit => 0, RaiseError => 1 });
 
-my $st = $DB->prepare("SELECT title, ndisc, path FROM old_dvd ORDER BY title");
+my $st = $DB->prepare
+  ("SELECT title, ndisc, path FROM old_dvd ORDER BY title");
 $st->execute;
 
-my $st1 = $DB->prepare("INSERT INTO dvd (title, disc, path) VALUES (?, ?, ?)");
-ROW: for (;;) {
-  my @r = $st->fetchrow_array; last ROW unless @r;
+my $st1 = $DB->prepare
+  ("INSERT INTO dvd (title, disc, path) VALUES (?, ?, ?)");
+while (my @r = $st->fetchrow_array) {
   my ($title, $ndisc, $path) = @r;
   print ";; $title [$ndisc]\n";
   for (my $i = 0; $i < $ndisc; $i++) { $st1->execute($title, $i, $path); }