App-DBBrowser

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

        - PageUP/PageDown: 'Ctrl-P'/'Ctrl-N' instead of 'Ctrl-B'/'Ctrl-F'.

2.279    2021-07-29
        - Bugfix in functions Epoch_to_Date/Epoch_to_DateTime: use driver specific regex statement.

2.278    2021-07-29
        - Removed the source type 'Copy&Paste'.
        - Removed option 'Truncated rows'.

2.277    2021-07-28
        - SQLite: replace 'sqlite_unicode' with 'sqlite_string_mode' if DBD::SQLite version >= 1.68.
        - Bugfix in 'attributes': use the values not the indexes.
        - Bugfix: apply DB specific setting immediately.

2.276    2021-07-20
        - Update export file_name.

2.275    2021-07-19
        - Update option auto-extension.
        - Bugfix export file_name.
        - Update UI filter.

lib/App/DBBrowser/Auxil.pm  view on Meta::CPAN

use Scalar::Util qw( looks_like_number );
#use Storable     qw();  # required

use JSON::MaybeXS   qw( decode_json );
use List::MoreUtils qw( none uniq );

use Term::Choose            qw();
use Term::Choose::Constants qw( EXTRA_W );
use Term::Choose::LineFold  qw( line_fold );
use Term::Choose::Screen    qw( clear_screen );
use Term::Choose::Util      qw( insert_sep get_term_width get_term_height unicode_sprintf );
use Term::Form::ReadLine    qw();


sub new {
    my ( $class, $info, $options, $d ) = @_;
    bless {
        i => $info,
        o => $options,
        d => $d
    }, $class;

lib/App/DBBrowser/Auxil.pm  view on Meta::CPAN

    }
    return $tmp;
}


sub __prepare_data_row {
    my ( $sf, $row, $indent, $term_w ) = @_;
    my $list_sep = ', ';
    no warnings 'uninitialized';
    my $row_str = join( $list_sep, map { s/\t/  /g; s/\n/\\n/g; s/\v/\\v/g; $_ } @$row );
    return unicode_sprintf( $indent . $row_str, $term_w, { suffix_on_truncate => $sf->{i}{dots} } );
}


sub print_sql_info {
    my ( $sf, $info, $waiting ) = @_;
    if ( ! defined $info ) {
        return;
    }
    print clear_screen();
    print $info, "\n";

lib/App/DBBrowser/DB.pm  view on Meta::CPAN


C<values> holds the available values for that attribute as an array reference.

The C<values> array entry of the index position C<default> is used as the default value.

Example from the plugin C<App::DBBrowser::DB::SQLite>:

    sub set_attributes {
        my ( $self ) = @_;
        return [
            { name => 'sqlite_unicode',             default => 1, values => [ 0, 1 ] },
            { name => 'sqlite_see_if_its_a_number', default => 1, values => [ 0, 1 ] },
        ];
    }

The information returned by the method C<set_attributes> is used to build the menu entry I<Set Attributes> in
L<db-browser/OPTIONS>.

=head4 read_attributes()

Returns a reference to an array of hashes. The hashes have one to two key-value pairs:

lib/App/DBBrowser/GetContent/Filter.pm  view on Meta::CPAN


use warnings;
use strict;
use 5.016;

use List::MoreUtils qw( any uniq );

use Term::Choose            qw();
use Term::Choose::Constants qw( EXTRA_W );
use Term::Choose::LineFold  qw( line_fold print_columns );
use Term::Choose::Util      qw( insert_sep get_term_width get_term_height unicode_sprintf );
use Term::Choose::Screen    qw( clear_screen );
use Term::Form              qw();
use Term::Form::ReadLine    qw();

use App::DBBrowser::Auxil;


sub new {
    my ( $class, $info, $options, $d ) = @_;
    my $sf = {

lib/App/DBBrowser/GetContent/Filter.pm  view on Meta::CPAN

    my $tu = Term::Choose::Util->new( $sf->{i}{tcu_default} );
    my $tf = Term::Form->new( $sf->{i}{tf_default} );
    my $aoa = $sql->{insert_args};
    my $term_w = get_term_width() + EXTRA_W;
    my $stringified_rows;
    {
        no warnings 'uninitialized';
        @$stringified_rows = map {
            my $str_row = join( ',', @$_ );
            if ( print_columns( $str_row ) > $term_w ) {
                $str_row = unicode_sprintf( $str_row, $term_w, { suffix_on_truncate => $sf->{i}{dots} } );
            }
            else {
                $str_row;
            }
        } @$aoa;
    }
    my $prompt = 'Choose rows:';
    my $info = $filter_str;
    # Choose
    my $chosen_idxs = $tu->choose_a_subset(

lib/App/DBBrowser/GetContent/Parse.pm  view on Meta::CPAN

use Encode qw( decode );

use Encode::Locale    qw();
#use Spreadsheet::Read qw( ReadData rows ); # required
#use String::Unescape  qw( unescape );      # required
#use Text::CSV_XS      qw();                # required

use Term::Choose           qw();
use Term::Choose::LineFold qw( line_fold );
use Term::Choose::Screen   qw( clear_screen );
use Term::Choose::Util     qw( get_term_size unicode_sprintf insert_sep );
use Term::Form             qw();

use App::DBBrowser::Opt::Set;


sub new {
    my ( $class, $info, $options, $d ) = @_;
    my $sf = {
        i => $info,
        o => $options,

lib/App/DBBrowser/GetContent/Parse.pm  view on Meta::CPAN

    if ( $avail_h < 5 ) { ##
        $avail_h = 5;
    }
    my $first_part_end = int( $avail_h / 1.5 );
    my $second_part_begin = $avail_h - $first_part_end;
    $first_part_end--;
    $second_part_begin--;
    my $end_idx = $#{$rows};
    if ( @$rows > $avail_h ) {
        for my $row ( @{$rows}[ 0 .. $first_part_end ] ) {
            $info .= "\n" . unicode_sprintf( $row, $term_w, { suffix_on_truncate => $sf->{i}{dots} } );
        }
        $info .= "\n[...]";
        for my $row ( @{$rows}[ $end_idx - $second_part_begin .. $end_idx ] ) {
            $info .= "\n" . unicode_sprintf( $row, $term_w, { suffix_on_truncate => $sf->{i}{dots} } );
        }
        my $row_count = scalar( @$rows );
        $info .= "\n" . unicode_sprintf( '[' . insert_sep( $row_count, $sf->{i}{info_thsd_sep} ) . ' rows]', $term_w, { suffix_on_truncate => $sf->{i}{dots} } );
    }
    else {
        for my $row ( @$rows ) {
            $info .= "\n" . unicode_sprintf( $row, $term_w, { suffix_on_truncate => $sf->{i}{dots} } );
        }
    }
    $info .= "\n";
    return $info;
}


sub parse_with_template {
    my ( $sf, $sql, $fh ) = @_;
    my $ax = App::DBBrowser::Auxil->new( $sf->{i}, $sf->{o}, $sf->{d} );



( run in 0.719 second using v1.01-cache-2.11-cpan-88abd93f124 )