#!/usr/bin/perl -w

use strict;
use DBI;

my $host = shift @ARGV || '';
$host = ";host=$host" if ($host);
my $user = shift @ARGV || "dpavlin";
my $pass = shift @ARGV || "";

my $sql = "SELECT sum(relpages) FROM pg_class";

my $dbh = DBI->connect("DBI:Pg:dbname=template1$host",$user,$pass) || die $DBI::errstr;
my $sth=$dbh->prepare($sql);

if ($sth->execute()) {
	print join("\n",$sth->fetchrow_array()),"\n";
}

undef $sth;
$dbh->disconnect();
