comparison scripts/migration/files_destination_step1_ @ 10:a50cf11e5178

Rewrite LGDataverse completely upgrading to dataverse4.0
author Zoe Hong <zhong@mpiwg-berlin.mpg.de>
date Tue, 08 Sep 2015 17:00:21 +0200
parents
children
comparison
equal deleted inserted replaced
9:5926d6419569 10:a50cf11e5178
1 #!/usr/bin/perl
2
3 use DBI;
4
5 my $host = "localhost";
6 my $username = "xxxxx";
7 my $password = 'xxxxx';
8 my $database = "xxxxx";
9
10 my $dbh = DBI->connect("DBI:Pg:dbname=$database;host=$host",$username,$password);
11 my $sth = $dbh->prepare(qq {SELECT d.protocol, d.authority, d.identifier, d.id, v.id, v.versionnumber FROM dataset d, datasetversion v WHERE v.dataset_id = d.id ORDER BY d.id, v.versionnumber});
12 $sth->execute();
13
14 my $offset= 0;
15
16 while ( @_ = $sth->fetchrow() )
17 {
18 $protocol = $_[0];
19 $authority = $_[1];
20 $identifier = $_[2];
21 $id = $_[3];
22 $vid = $_[4];
23 $vnum = $_[5];
24
25 print $protocol . ":" . $authority . "/" . $identifier . "\t" . $id . "\t" . $vid . "\t" . $vnum . "\n";
26
27 $offset = $id;
28 }
29
30 $sth->finish;
31 $dbh->disconnect;
32
33 print STDERR "last ID in DVOBJECT table: " . $offset . "\n";
34
35 exit 0;
36