use Mojolicious::Lite; use MyApp; my $moo = MyApp->new(); get '/foo' => sub { my $c = shift; my $query = qq(select nose from myTable); my $dbh = $moo->dbh; my $sth = $moo->txn( sub { my $sth = $dbh->prepare($query); $sth->execute; $sth; } ); my $row = $sth->fetch; $c->render( text => "

$row->[0]

" ); }; get '/bar' => sub { my $c = shift; my $query = qq(select monk from myTable); my $dbh = $moo->dbh; my $sth = $moo->txn( sub { my $sth = $dbh->prepare($query); $sth->execute; $sth; } ); my $row = $sth->fetch; $c->render( text => "

$row->[0]

" ); }; app->start; __END__