#!/bin/env perl package MySQL::Slurp::App; use Moose; use self; # use Data::Dumper; use Pod::Usage; extends 'MySQL::Slurp'; with 'MooseX::Getopt'; # Enable pass_through # This is important since we will pass_through # remaining options to mysqlimport. # # print Dumper &Getopt::Long::Configure; &Getopt::Long::Configure( qw( pass_through auto_version ) ); has 'tmp' => ( is => 'rw' , isa => 'Str' , required => 1 , default => $ENV{ TMPDIR } || $ENV{ TMP } || '/tmp' || '.' , metaclass => 'MooseX::Getopt::Meta::Attribute' , cmd_aliases => [ 'tmpdir', 'temp' ] , documentation => 'Directory to hold the pipe. Default: ' . ( $ENV{TMPDIR} || $ENV{TMP} || ( (-d '/tmp' && -w '/tmp' ) ? '/tmp' : 0 ) || '.' ) ); has 'database' => ( is => 'rw' , isa => 'Str' , required => 1 , metaclass => 'MooseX::Getopt::Meta::Attribute' , cmd_aliases => [ 'D' ] , documentation => 'Database' ); has 'table' => ( is => 'rw' , isa => 'Str' , required => 1 , metaclass => 'MooseX::Getopt::Meta::Attribute' , documentation => 'Table' ); has 'args' => ( is => 'rw' , isa => 'ArrayRef' , required => 0 , lazy => 1 , default => sub { self->extra_argv } , # sub { $_[0]->extra_argv } , documentation => 'Options passed to mysqlimport' ); has 'usage' => ( is => 'rw' , isa => 'Bool' , required => 0 , trigger => sub { pod2usage } , metaclass => 'MooseX::Getopt::Meta::Attribute' , cmd_aliases => [ 'help', '?' ] , documentation => 'Print usage information and exit' , ); has 'man' => ( is => 'rw' , isa => 'Bool' , required => 0 , trigger => sub { pod2usage( -verbose => 3 ) } , documentation => 'Print man page and exit' , ); package main; use Data::Dumper; our $VERSION = '0.84'; my $slurp = MySQL::Slurp::App->new_with_options; $slurp->open; $slurp->slurp; $slurp->close; __END__ =head1 NAME mysqlslurp - slurp into a MySQL table =head1 SYNOPSIS mysqlslurp -D | --database Database --table Table [--tmp | --tmpdir | --temp ] Temporary Directory [ --usage ] Prints this synopsis [ --man ] Prints full man page [options passed to mysqlimport] ( see mysqlimport --help for a list of options ) Example: cat file | mysqlimport --database=my_db --table=my_table =head1 DESCRIPTION mysqlslurp reads from and writes to directly to a MySQL table. Parameters --database and --table are required. Specifying a --tmp directory where the FIFO pipe will be created is optional. All other options are passed to B unchanged. =head1 ADVANTAGES =over 4 =item Speed mysqlslurp wraps mysqlimport, the fastest way to import data into MySQL tables. Especially with the --use-threads option. =item Data in Motion Unlike B, B does not require that the data be resident in a file on disk. This is handy in multiple server setups. =item Good Defaults Mostly just works. =head1 SEE ALSO L mysqlimport at L, currently L =head1 AUTHOR Christopher Brown, Ectbrown@cpan.org L =head1 COPYRIGHT AND LICENSE Copyright (C) 2008 by Open Data This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available. =cut