DBIx::FixtureLoader - Loading fixtures and inserting to your database
use DBI; use DBIx::FixtureLoader; my $dbh = DBI->connect(...); my $loader = DBIx::FixtureLoader->new(dbh => $dbh); $loader->load_fixture('item.csv');
DBIx::FixtureLoader is to load fixture data and insert to your database.
$loader = DBIx::FixtureLoader->new(%option)
new is Constructor method. Various options may be set in
%option, which affect the behaviour of the object (Type and defaults in parentheses):
Required. Database handler.
Using bulk_insert or not. Default value depends on your database.
INSERT ON DUPLICATE or not. It only works on MySQL.
INSERT IGNORE or not. This option is exclusive with
Specifying Text::CSV's option.
blank_is_undef are automatically set.
Loading fixture and inserting to your database. Table name and file format is guessed from file name. For example, "item.csv" contains data of "item" table and format is "CSV".
In most cases
%option is not needed. Available keys of
%option are as follows.
table name of database.
data format. "CSV", "YAML" and "JSON" are available.
ON DUPLICATE KEY UPDATE or not. Default value depends on object setting.
INSERT IGNORE or not.
Data format is guessed from extension. Table name is guessed from basename. Leading alphabets, underscores and numbers are considered table name. So,
"user_item-2.csv" is considered CSV format and containing data of "user_item" table.
"CSV", "YAML" and "JSON" are parsable. CSV file must have header line for determining column names.
Datas in "YAML" or "JSON" must be ArrayRef or HashRef containing HashRefs. Each HashRef is the data of database record and keys of HashRef is matching to column names of the table.
Copyright (C) Masayuki Matsuki.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Masayuki Matsuki <firstname.lastname@example.org>