6 use MARC::File::USMARC;
12 use Time::HiRes qw(gettimeofday);
15 my ( $input_marc_file, $number) = ('',0);
24 Script to create the zebra DB from a Koha DB
31 $|=1; # flushes output
33 my $dbh = C4::Context->dbh;
36 $Zconn = new ZOOM::Connection('localhost','2100');
39 print "Error ", $@->code()," : ",$@->message()."\n";
43 # first, drop Zebra DB
45 my $Zpackage = $Zconn->package();
46 $Zpackage->option(databaseName => 'Koha');
47 # $Zpackage->send("drop");
51 my $Zpackage = $Zconn->package();
52 $Zpackage->option(databaseName => 'Koha');
53 $Zpackage->send("create");
55 my $cgidir = C4::Context->intranetdir ."/cgi-bin";
56 unless (opendir(DIR, "$cgidir")) {
57 $cgidir = C4::Context->intranetdir."/";
60 my $starttime = gettimeofday;
61 my $sth = $dbh->prepare("select biblionumber from biblio");
64 while ((my $biblionumber) = $sth->fetchrow) {
65 my $record = XMLgetbiblio($dbh,$biblionumber);
66 my $Zpackage = $Zconn->package();
67 $Zpackage->option(databaseName => 'Koha');
68 $Zpackage->option(action => "recordInsert");
69 $Zpackage->option(record => $record);
70 $Zpackage->send("update");
74 print "$i\r" unless ($i % 100);
77 my $Zpackage = $Zconn->package();
78 $Zpackage->option(databaseName => 'Koha');
79 $Zpackage->send("commit");
80 my $timeneeded = gettimeofday - $starttime;
81 print "\n\n$i MARC record done in $timeneeded seconds\n";