sub new { bless {}; shift } sub connect { my $self = shift; my %param = @_; my $table = "cf_status_log"; my $dbh = DBI->connect( "DBI:Pg:dbname=$param{'db_name'}; host=$param{'db_host'}", "$param{'db_user'}", "$param{'db_pass'}", { RaiseError => 1 } ) or die "Could not connect to database"; return $dbh; }; sub inventory_query { my $dbh = shift; my $result = $dbh->prepare( "SELECT * FROM dr_inventory_classes" ) || die "Could not prepare" ; } 1; #### use lib 'lib'; use DeltaR; my $dr = DeltaR->new; sub dbh { my $self = shift; my $dbh = $dr->connect( db_name => "postgres", db_user => "postgres", db_pass => "", db_host => "127.0.0.1" ); return $dbh; }; get '/inventory' => sub { my $self = shift; my $dbh = dbh; my $rows = $dr->query_inventory( $dbh ); $self->stash( title => "Inventory report", record_limit => $record_limit, rows => $rows, columns => [ 'Count', 'Class' ] ); } => "rtable"; app->start;