++ed by:
VOJ

1 PAUSE user(s)

Nicolas Steenlant

NAME

Catmandu::Store::DBI - A Catmandu::Store plugin for DBI based interfaces

VERSION

Version 0.02

SYNOPSIS

    use Catmandu::Store::DBI;

    my $store = Catmandu::Store::DBI->new(
        data_source => 'DBI:mysql:database=test', # prefix "DBI:" optionl
        username => '', # optional
        password => '', # optional
    );

    my $obj1 = $store->bag->add({ name => 'Patrick' });

    printf "obj1 stored as %s\n" , $obj1->{_id};

    # Force an id in the store
    my $obj2 = $store->bag->add({ _id => 'test123' , name => 'Nicolas' });

    my $obj3 = $store->bag->get('test123');

    $store->bag->delete('test123');

    $store->bag->delete_all;

    # All bags are iterators
    $store->bag->each(sub { ... });
    $store->bag->take(10)->each(sub { ... });

The catmandu command line client can be used like this:

    catmandu import JSON to DBI --data_source SQLite:mydb.sqlite < data.json
    

DESCRIPTION

A Catmandu::Store::DBI is a Perl package that can store data into DBI backed databases. The database as a whole is called a 'store' (Catmandu::Store. Databases also have compartments (e.g. tables) called 'bags' (Catmandu::Bag).

METHODS

new(data_source => $data_source)

Create a new Catmandu::Store::DBI store using a DBI $data_source. The prefix "DBI:" is added automatically if needed.

bag($name)

Create or retieve a bag with name $name. Returns a Catmandu::Bag.

AUTHOR

Nicolas Steenlant, <nicolas.steenlant at ugent.be>

CONTRIBUTOR

Vitali Peil <vitali.peil at uni-bielefeld.de>

CONTRIBUTOR

Nicolas Franck <nicolas.franck at ugent.be>

SEE ALSO

Catmandu::Bag, Catmandu::Searchable, DBI