pldb: Correct the usage for the `list' command.
[dvddb] / upgrade-v2
1 #! /usr/bin/perl -w
2
3 use open ":utf8";
4 use strict;
5
6 use DBI;
7
8 BEGIN { binmode STDOUT, ":utf8"; }
9
10 my $DB = DBI->connect("dbi:Pg:host=roadstar", "", "",
11 { AutoCommit => 0, RaiseError => 1 });
12
13 my $st = $DB->prepare
14 ("SELECT title, ndisc, path FROM old_dvd ORDER BY title");
15 $st->execute;
16
17 my $st1 = $DB->prepare
18 ("INSERT INTO dvd (title, disc, path) VALUES (?, ?, ?)");
19 while (my @r = $st->fetchrow_array) {
20 my ($title, $ndisc, $path) = @r;
21 print ";; $title [$ndisc]\n";
22 for (my $i = 0; $i < $ndisc; $i++) { $st1->execute($title, $i, $path); }
23 }
24 $DB->commit; $DB->disconnect;