Acrux-DBI
view release on metacpan or search on metacpan
lib/Acrux/DBI/Dump.pm view on Meta::CPAN
package Acrux::DBI::Dump;
use strict;
use utf8;
=encoding utf8
=head1 NAME
Acrux::DBI::Dump - Working with SQL dumps
=head1 SYNOPSIS
use Acrux::DBI::Dump;
my $dump = Acrux::DBI::Dump->new(
dbi => $dbi
);
$dump->from_file('/tmp/test.sql')->poke;
=head1 DESCRIPTION
This class is used by L<Acrux::DBI> to allow database schemas import.
A dump file is just a collection of sql blocks, with one or more statements, separated by comments of the form
C<-- #NAME> or C<-- # NAME>
-- #foo
CREATE TABLE `pets` (`pet` TEXT);
INSERT INTO `pets` VALUES ('cat');
INSERT INTO `pets` VALUES ('dog');
delimiter //
CREATE PROCEDURE `test`()
BEGIN
SELECT `pet` FROM `pets`;
END
//
-- #bar
DROP TABLE `pets`;
DROP PROCEDURE `test`;
-- #baz (...you can comment freely here...)
-- ...and here...
CREATE TABLE `stuff` (`whatever` INT);
-- #main
DROP TABLE `stuff`;
This idea is to let you import SQL dumps step by step by its names
=head1 ATTRIBUTES
This class implements the following attributes
=head2 dbi
$dump = $dump->dbi($dbi);
my $dbi = $dump->dbi;
The object these processing belong to
=head2 name
my $name = $dump->name;
$dump = $dump->name('foo');
( run in 3.061 seconds using v1.01-cache-2.11-cpan-5735350b133 )