Commit | Line | Data |
---|---|---|
14acb11f MW |
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("SELECT title, ndisc, path FROM old_dvd ORDER BY title"); | |
14 | $st->execute; | |
15 | ||
16 | my $st1 = $DB->prepare("INSERT INTO dvd (title, disc, path) VALUES (?, ?, ?)"); | |
17 | ROW: for (;;) { | |
18 | my @r = $st->fetchrow_array; last ROW unless @r; | |
19 | my ($title, $ndisc, $path) = @r; | |
20 | print ";; $title [$ndisc]\n"; | |
21 | for (my $i = 0; $i < $ndisc; $i++) { $st1->execute($title, $i, $path); } | |
22 | } | |
23 | $DB->commit; $DB->disconnect; |