9 |
use Data::Dump qw/dump/; |
use Data::Dump qw/dump/; |
10 |
use Time::HiRes qw/time/; |
use Time::HiRes qw/time/; |
11 |
|
|
12 |
|
print qq{Content-type: text/html\r\n\r\n}; |
13 |
|
|
14 |
our $dsn = 'DBI:Pg:dbname=syslog'; |
our $dsn = 'DBI:Pg:dbname=syslog'; |
15 |
our $user = 'dpavlin'; |
our $user = 'dpavlin'; |
16 |
our $table = 'log'; |
our $table = 'log'; |
32 |
|
|
33 |
my $dbh = DBI->connect( $dsn, $user, '', { RaiseError => 1 } ) || die $DBI::errstr; |
my $dbh = DBI->connect( $dsn, $user, '', { RaiseError => 1 } ) || die $DBI::errstr; |
34 |
|
|
35 |
if ( my $group_by = param('add_group_by') ) { |
if ( my $group_by = param('lookup_col') ) { |
36 |
|
|
37 |
my @cols = ( $group_by, "count($group_by)" ); |
my @cols = ( $group_by, "count($group_by)" ); |
38 |
my @group_by = ( $group_by ); |
my @group_by = ( $group_by ); |
65 |
my $sth = $dbh->prepare( $sql ); |
my $sth = $dbh->prepare( $sql ); |
66 |
$sth->execute; |
$sth->execute; |
67 |
$t = time() - $t; |
$t = time() - $t; |
68 |
print header, qq|$t<table><tr><th>|, join(qq|</th><th>|, @cols), qq|</th></tr>|; |
print qq|$t<table><tr><th>|, join(qq|</th><th>|, @cols), qq|</th></tr>|; |
69 |
while ( my @row = $sth->fetchrow_array ) { |
while ( my @row = $sth->fetchrow_array ) { |
70 |
my $n = shift @row; |
my $n = shift @row; |
71 |
$n = 'NULL' unless defined $n; |
$n = 'NULL' unless defined $n; |
76 |
exit; |
exit; |
77 |
} |
} |
78 |
|
|
79 |
print header, q| |
print q| |
80 |
|
|
81 |
<html> |
<html> |
82 |
<head> |
<head> |
171 |
|
|
172 |
print |
print |
173 |
qq|</table>| |
qq|</table>| |
174 |
, start_form( -id => 'sql' ) |
, start_form( -id => 'sql', -class => 'fixed' ) |
175 |
|
|
176 |
, qq|<a href="#" onclick="\$('form#sql').toggleClass('visible'); return false;" class=close title="hide sql editor">[x]</a>| |
, qq|<input type=button value="[=]" onclick="\$('form#sql').toggleClass('fixed'); return false;" title="toggle fixed position" class="right">| |
177 |
|
, qq|<input type=button value="[x]" onclick="\$('form#sql').toggleClass('visible'); return false;" title="hide sql editor" class="right">| |
178 |
|
|
179 |
, qq|<label for=columns>select</label>| |
, qq|<label for=columns>select</label>| |
180 |
, checkbox_group( -name => 'columns', -values => [ @columns ], -defaults => [ @columns ] ) |
, checkbox_group( -name => 'columns', -values => [ @columns ], -defaults => [ @columns ] ) |
189 |
, textfield( -name => 'where_value' ) |
, textfield( -name => 'where_value' ) |
190 |
, qq| |
, qq| |
191 |
<span> |
<span> |
192 |
<input type=button name=add_group_by> |
<input type=button name=lookup_col title="lookup column details"> |
193 |
<input type=button name=close_group_by value="[x]" disabled=1> |
<input type=button name=close_group_by value="[x]" disabled=1> |
194 |
<div id="lookup"></div> |
<div id="lookup"></div> |
195 |
<span> |
<span> |