source: trunk/third/moira/gen/warehouse.gen @ 26024

Revision 26024, 1.0 KB checked in by jdreed, 11 years ago (diff)
In moira: * Snapshot moira at r4113 to pick up new firewall-related changes
  • Property svn:executable set to *
Line 
1#!/moira/bin/perl -Tw
2#
3# $Id: warehouse.gen 4113 2013-05-28 14:29:10Z zacheiss $
4# Generate a database extract from the users table for the MIT Data Warehouse.
5$MR_DBMS_ERR = 47836421;
6$MR_OCONFIG = 47836460;
7
8$outfile = '/moira/dcm/warehouse.out';
9
10use DBI;
11
12$dbh = DBI->connect("dbi:Oracle:moira", "moira", "moira") || exit $MR_DBMS_ERR;
13
14$sth = $dbh->prepare("SELECT login, clearid, first, last, middle " .
15                     "FROM users WHERE (status = 1 OR status = 2 OR " .
16                     "status = 5 OR status = 6 OR status = 7 OR status = 9 OR status = 10 " .
17                     "OR status = 11 OR status = 12)");
18
19$sth->execute || exit $MR_DBMS_ERR;
20
21umask 022;
22open(OUT, ">$outfile") || exit $MR_OCONFIG;
23
24while (($login, $clearid, $first, $last, $middle) = $sth->fetchrow_array) {
25    next if (length($clearid) < 2);
26    next if ($clearid eq "0" || $clearid eq "\0" || $clearid =~ /^.\D/);
27    $row = "$login\t$clearid\t$first\t$last\t$middle\n";
28    $row =~ s/\0//g;
29    print OUT $row;
30}
31
32close(OUT);
33$dbh->disconnect;
34
35exit 0;
Note: See TracBrowser for help on using the repository browser.