Data::Record::Serialize::Encode::dbi - store a record in a database
version 0.13
use Data::Record::Serialize; my $s = Data::Record::Serialize->new( encode => 'sqlite', ... ); $s->send( \%record );
Data::Record::Serialize::Encode::dbi writes a record to a database using DBI.
It performs both the Data::Record::Serialize::Role::Encode and Data::Record::Serialize::Role::Sink roles.
You cannot construct this directly; you must use Data::Record::Serialize->new.
Field types are recognized and converted to SQL types via the following map:
S => 'text' N => 'real' I => 'integer'
Records are by default written to the database in batches (see the batch attribute) to improve performance. Each batch is performed as a single transaction. If there is an error during the transaction, record insertions during the transaction are not rolled back.
batch
These attributes are available in addition to the standard attributes defined for Data::Record::Serialize->new.
dsn
Required The DBI Data Source Name (DSN) passed to DBI. It may either be a string or an arrayref containing strings or arrayrefs, which should contain key-value pairs. Elements in the sub-arrays are joined with =, elements in the top array are joined with :. For example,
=
:
[ 'SQLite', { dbname => $db } ]
is transformed to
SQLite:dbname=$db
The standard prefix of dbi: will be added if not present.
dbi:
table
Required The name of the table in the database which will contain the records. It will be created if it does not exist.
schema
The schema to which the table belongs. Optional.
drop_table
If true, the table is dropped and a new one is created.
create_table
If true, a table will be created if it does not exist.
primary
A single output column name or an array of output column names which should be the primary key(s). If not specified, no primary keys are defined.
db_user
The name of the database user
db_pass
The database password
The number of rows to write to the database at once. This defaults to 100.
If greater than 1, batch rows are cached and then sent out in a single transaction. See "Performance" for more information.
dbitrace
A trace setting passed to DBI.
You can make new bug reports, and view existing ones, through the web interface at https://rt.cpan.org/Public/Dist/Display.html?Name=Data-Record-Serialize.
Please see those modules/websites for more information related to this module.
Data::Record::Serialize
Diab Jerius <djerius@cpan.org>
This software is Copyright (c) 2017 by Smithsonian Astrophysical Observatory.
This is free software, licensed under:
The GNU General Public License, Version 3, June 2007
To install Data::Record::Serialize, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Data::Record::Serialize
CPAN shell
perl -MCPAN -e shell install Data::Record::Serialize
For more information on module installation, please visit the detailed CPAN module installation guide.