Database-Async-Engine-PostgreSQL
view release on metacpan or search on metacpan
examples/roundtrip.pl view on Meta::CPAN
# options here are those which stream arrayrefs (or ignore the output)
->row_arrayrefs
->map(sub {
$log->infof(
'ID %s has name %s with creation date %s',
@$_
)
})
->completed;
$log->infof('Copy data in');
# Normally you'd have a proper source that's streaming from some other system,
# this construct looks a bit unwieldy on its own but the ->from method
# would also accept the arrayref-of-rows directly.
await $db->query('copy roundtrip_one(name) from stdin')
->from([ map [ $_ ], qw(first second third) ])
->completed;
$log->infof('Find those rows again:');
await $db->query(q{select * from roundtrip_one where name in ('first', 'second', 'third') order by id})
->row_hashrefs
->map(sub {
lib/Database/Async/Engine/PostgreSQL.pm view on Meta::CPAN
} else {
$log->errorf('Received error %s with no active query', $msg->error);
}
}),
copy_in_response => $self->$curry::weak(sub {
my ($self, $msg) = @_;
my $query = $self->active_query;
$log->tracef('Ready to copy data for %s', $query);
my $proto = $self->protocol;
{
my $src = $query->streaming_input;
$src->completed
->on_ready(sub {
my ($f) = @_;
$log->tracef('Sending copy done notification, stream status was %s', $f->state);
$proto->send_message(
'CopyDone',
data => '',
);
$proto->send_message(
'Close',
( run in 0.233 second using v1.01-cache-2.11-cpan-4d50c553e7e )