The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Coro::DBI - asynchronous DBI access

SYNOPSIS

    use Coro::DBI;

    async {
        # some asynchronous thread
        my $i=0;
        while ($i++) {
            print "$i\n";
        }
    };

    my $dbh = DBI->connect("DBI:SQLite:dbname=test.db", "", "");

    my $sth = $dbh->prepare("select * from test where num=?");

    $sth->execute(10);

    while (my @row = $sth->fetchrow_array) {
        print "@row\n";
    }

    $sth->finish;

    $dbh->disconnect;

DESCRIPTION

This module changes the behavior of DBI::connect to move connections into a child process so they will not block other coros. It should be used before the first database connection is made.

CLASS METHODS

None of these methods need to be called for normal operation.

start Coro::DBI->start($tcp_port);

Starts the dbi_proxy child process.

stop Coro::DBI->stop;

Kills the dbi_proxy child process with SIGINT.

proxy_dsn $prefix = Coro::DBI->dsn_prefix

Returns the DBD::Proxy part of the data_source so it can be prepended to your data source when connecting.

You do not need to use the proxy_dsn directly.

SEE ALSO

Coro, DBI, AnyEvent::DBI, Coro::Mysql

AUTHOR

Eric Clark, <eclark at genome.wustl.edu>

BUGS

Currently uses a hard-coded default TCP port 5001.

Suffers from the same bugs and limitations as DBD::Proxy.

dbi_proxy child process will not shutdown automatically unless you are on Linux i386 or x86_64