Catmandu::Store::DBI - A Catmandu::Store plugin for DBI based interfaces
use Catmandu::Store::DBI; my $store = Catmandu::Store::DBI->new(data_source => 'DBI:mysql:database=test'); 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 { ... });
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'. Databases also have compartments (e.g. tables) called Catmandu::Bag-s.
Create a new Catmandu::Store::DBI store using a DBI $data_source.
Create or retieve a bag with name $name. Returns a Catmandu::Bag.
Catmandu::Bag, Catmandu::Searchable, DBI
To install Catmandu, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Catmandu
CPAN shell
perl -MCPAN -e shell install Catmandu
For more information on module installation, please visit the detailed CPAN module installation guide.