LRpt

 view release on metacpan or  search on metacpan

lib/LRpt/CSVDumper.pm  view on Meta::CPAN

Selects to be executed can be given either on standard input or in a file.
See L</SELECTS DEFINITION> for details.

=head1 COMMAND LINE OPTIONS

=over 4

=item C<--ext>

Extension of csv files created. Default is "txt"

=item C<--path>

Path in which csv files are to be created. Default is a current directory

=item C<--sep>

Fields separator in csv files. Default is tab

=item C<--conn_file>

Path to a database connection file. Default is C<conn_file.txt>.

=item C<--help>

Prints help screen

=item C<--chunk_size>

Number of rows retrieved in one chunk. If not defined - default chunking size
is used. If equal to zero, than no chunking is used (all rows are loaded
to memory

=item C<selects.txt>

File with selects to be executed.

=back

=head1 METHODS

In this sections you will find a more or less complete listing of all
methods provided by the package. 

=cut

########################################################################

=head2 C<dump_selects>

  dump_selects( @ARGV );

Equivalent of a 'main' function. For meaning of parameters see
L<COMMAND LINE OPTIONS|"COMMAND LINE OPTIONS">.

=cut

########################################################################
sub dump_selects
{
    local ( @ARGV ) = @_;
    set_params();
    run_selects();
} 

########################################################################

=head2 C<set_params>

  set_params();

Parses command line parameters, checks environmental variables to gather
all parameters needed to process.

=cut

########################################################################
sub set_params
{
    my $ext       = "";
    my $path      = "";
    my $sep       = "";
    my $conn_file = "";
    my $help      = "";
    my $chunk_size = undef;

    GetOptions( "ext=s"       => \$ext,
                "path=s"      => \$path,
                "sep=s"       => \$sep,
                "conn_file=s" => \$conn_file,
                "chunk_size=s"   => \$chunk_size,
                "help"        => \$help );

    if( $help ){
        print_usage();
    }
    my $config = LRpt::Config->new( 'ext'       => $ext,
                                    'path'      => $path,
                                    'sep'       => $sep,
                                    'conn_file' => $conn_file,
                                    'chunk_size' => $chunk_size );
    open_db_connection();
} 

########################################################################

=head2 C<open_db_connection>

  open_db_connection()

Opens a database connection. Loads a connection file and evals it.

=cut

########################################################################
sub open_db_connection
{
    my $config = LRpt::Config->new();
    my $conn_file = "conn_file.txt";
    if( not -e $conn_file ){
        $conn_file = $config->get_value( 'conn_file' );



( run in 1.852 second using v1.01-cache-2.11-cpan-364913b4093 )