-
-
Save anonymous/6ec9822376016aed9486 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
use v5.10; | |
use Mojo::Pg; | |
use Mojo::IOLoop; | |
my $pg = Mojo::Pg->new('postgresql://tester:testing@/test')->max_connections(1)->max_statements(1); | |
$pg->db->query(q{create table if not exists qwe (num integer, text text)}); | |
$pg->db->query(q{truncate qwe}); | |
Mojo::IOLoop->delay( | |
sub { | |
my $delay = shift; | |
my $db = $pg->db; | |
warn $db->dbh; | |
$db->query(q{insert into qwe(num, text) values (?, ?)}, 1, '1' => $delay->begin(0)); | |
}, | |
sub { | |
my ($delay, $db, $err, $results) = @_; | |
warn $db->dbh; | |
$db->ping; | |
$db->query(q{insert into qwe(num, text) values (?, ?)}, 1, '1' => $delay->begin); | |
say $db->dbh->pg_ready ? 'READY' : 'NOT READY' for 1 .. 100; | |
}, | |
sub { Mojo::IOLoop->stop } | |
); | |
Mojo::IOLoop->start; | |
$pg->db->query('drop table qwe'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment