On Sun, Feb 4, 2018 at 4:04 AM, sri <kra...@gmail.com> wrote:
>
> There's a lot wrong with this. You should hold on to $db objects, there's
> a pool of connections in
> Mojo::Pg. Manual prepare/execute is pointless, Mojo::Pg::Database has a
> transparent statement
> handle cache, once you hold on to the $db object you get caching for free
> without having to do
> anything. Just pass the same data structure to ->insert or same SQL to
> ->query and you're done.
>

Thanks for the feedback!  Is this a correct implementation of what you're
saying?

my $db = $pg->db;
my $results = $db->select('a', [qw/first last birthday age phone/], undef,
{limit => $limit, offset => 1});
my $tx = $db->begin;
while ( my $next = $results->hash ) {
  $db->insert('b', $next);
}
$tx->commit;

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.

Reply via email to