3 # This script generates 80,000 random records in the kohabenchmark database for
4 # the purposes of comparing two different marc storage schemas. It requires
5 # the presence of a word list for populating the data. Mine is in
6 # /usr/share/dict/words. Change that if necessary. You'll also need to change
7 # your userid and password for the dbi->connect line.
11 my $dbh=DBI->connect("dbi:mysql:kohabenchmark", 'youruserid', 'yourpassword');
12 @subfields = ( 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n');
15 open (W, "/usr/share/dict/words");
22 my $subfieldcounter=0;
24 for ($bibid=1; $bibid<80000; $bibid++) {
25 my $numtags=int(rand(10)+5);
26 my $localtagcounter=0;
27 for ($i=1; $i<$numtags; $i++) {
31 my $numsubfields=int(rand(10)+1);
33 my $localsubfieldcounter=0;
35 for ($j=1; $j<=$numsubfields; $j++) {
38 my $codepicker=int(rand($#subfields));
39 if ($subfieldsused->{$subfields[$codepicker]}==0) {
40 $subfieldsused->{$subfields[$codepicker]}=1;
41 $code=$subfields[$codepicker];
45 $localsubfieldcounter++;
46 my $word=$words[int(rand($#words))];
47 $tagvalue.="\$$code $word\0";
48 my $sth=$dbh->prepare("insert into marc_2XX_subfield_table (subfieldid, tagid, tag, bibid, subfieldorder, subfieldcode, subfieldvalue) values (?,?,?,?,?,?,?)");
51 $sth->execute($subfieldcounter, $tagcounter, $tag, $bibid, $localsubfieldcounter, $code, $word);
55 print "ERROR: $error\n";
62 my $sth=$dbh->prepare("insert into marc_0XX_tag_table (bibcode, tagnumber, tagorder, tagvalue) values (?, ?, ?, ?)");
64 $sth->execute($bibid, $tag, $localtagcounter, $tagvalue);
68 print "ERROR: $error\n";