Annotation of db/prgsrc/stats.pl, revision 1.1
1.1 ! boris 1: #!/usr/bin/perl
! 2: #
! 3: # Get statistics for the database in the form
! 4: # Date total_questions distinct_questions
! 5: #
! 6: use DBI;
! 7: use CGI ':all';
! 8: use strict;
! 9:
! 10: require "dbdefs.pl";
! 11: my $dbuser||="piataev";
! 12: my $dbname||="chgk";
! 13: my $dbpass||="";
! 14: my $dbhost||="localhost";
! 15:
! 16:
! 17: my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday) =
! 18: gmtime(time);
! 19: $year += 1900;
! 20: my @names=('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat');
! 21: $wday=$names[$wday];
! 22:
! 23: printf "$wday %04d-%02d-%02d %02d:%02d:%02d GMT ", $year,$mon,$mday,$hour,$min,$sec;
! 24:
! 25: my($dsn) = "DBI:mysql:database=$dbname;host=$dbhost";
! 26: my $dbh = DBI->connect($dsn, $dbuser, $dbpass) || die "Cannot connect\n";
! 27:
! 28: my ($sth) = $dbh->prepare("SELECT COUNT(*) FROM Questions");
! 29: $sth->execute;
! 30: my $total=($sth->fetchrow)[0];
! 31: $sth->finish;
! 32: $sth= $dbh -> prepare("select distinct count(first) FROM equalto");
! 33: $sth -> execute;
! 34: my ($equal)=$sth->fetchrow;
! 35: $sth -> finish;
! 36:
! 37: print " $total ",$total-$equal, "\n";
! 38:
! 39: $dbh->disconnect;
! 40:
! 41: exit 0;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>