File: README

package info (click to toggle)
libanyevent-dbd-pg-perl 0.03-4
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 212 kB
  • ctags: 149
  • sloc: perl: 2,186; makefile: 2
file content (101 lines) | stat: -rw-r--r-- 3,384 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
NAME
    AnyEvent::DBD::Pg - AnyEvent interface to DBD::Pg's async interface

SYNOPSIS
        use AnyEvent::DBD::Pg;

        my $adb = AnyEvent::DBD::Pg->new('dbi:Pg:dbname=test', user => 'pass', {
            pg_enable_utf8 => 1,
            pg_server_prepare => 0,
            quote_char => '"',
            name_sep => ".",
        }, debug => 1);

        $adb->queue_size( 4 );
        $adb->debug( 1 );

        $adb->connect;

        $adb->selectcol_arrayref("select pg_sleep( 0.1 ), 1", { Columns => [ 1 ] }, sub {
            my $rc = shift or return warn;
            my $res = shift;
            warn "Got <$adb->{qd}> = $rc / @{$res}";
            $adb->selectrow_hashref("select data,* from tx limit 2", {}, sub {
                my $rc = shift or return warn;
                warn "Got $adb->{qd} = $rc [@_]";
            });
        });

        $adb->execute("update tx set data = data;",sub {
            my $rc = shift or return warn;
            warn "Got exec: $rc";
            #my $st = shift;
            #$st->finish;
        });

        $adb->execute("select from 1",sub {
            shift or return warn;
            warn "Got $adb->{qd} = @_";
        });

        $adb->selectrow_array("select pg_sleep( 0.1 ), 2", {}, sub {
            shift or return warn;
            warn "Got $adb->{qd} = [@_]";
            $adb->selectrow_hashref("select * from tx limit 1", {}, sub {
                warn "Got $adb->{qd} = [@_]";
                $adb->execute("select * from tx", sub {
                    my $rc = shift or return warn;
                    my $st = shift;
                    while(my $row = $st->fetchrow_hashref) { warn "$row->{id}"; }
                    $st->finish;
                    exit;
                });
            });
        });
        AE::cv->recv;

METHODS
    connect()
        Establish connection to database

    selectrow_array( $query, [\%args], $cb->( $rc, ... ))
        Execute PG_ASYNC prepare, than push result of "fetchrow_array" into
        callback

    selectrow_arrayref( $query, [\%args], $cb->( $rc, \@row ))
        Execute PG_ASYNC prepare, than push result of "fetchrow_arrayref"
        into callback

    selectrow_hashref( $query, [\%args], $cb->( $rc, \%row ))
        Execute PG_ASYNC prepare, than push result of "fetchrow_hashref"
        into callback

    selectall_arrayref( $query, [\%args], $cb->( $rc, \@rows ))
        Execute PG_ASYNC prepare, than push result of "fetchall_arrayref"
        into callback

    selectall_hashref( $query, [\%args], $cb->( $rc, \@rows ))
        Execute PG_ASYNC prepare, than push result of "fetchall_hashref"
        into callback

    selectcol_arrayref( $query, { Columns => [...], ... }, $cb->( $rc,
    \@rows ))
        Execute PG_ASYNC prepare, than push result of
        "fetchall_hashref($args{Columns})" into callback

    execute( $query, [\%args], $cb->( $rc, $sth ))
        Execute PG_ASYNC prepare, than invoke callback, pushing resulting
        sth to it.

        Please, note: result already passed as first argument

AUTHOR
    Mons Anderson, "<mons@cpan.org>"

LICENSE AND COPYRIGHT
    Copyright 2010 Mons Anderson.

    This program is free software; you can redistribute it and/or modify it
    under the terms of either: the GNU General Public License as published
    by the Free Software Foundation; or the Artistic License.