App-DBBrowser

 view release on metacpan or  search on metacpan

bin/db-browser  view on Meta::CPAN

#!/usr/bin/env perl
use warnings;
use strict;
use 5.016;
our $VERSION = '2.440';

use Term::Choose::Screen qw( hide_cursor show_cursor clear_to_end_of_screen );

use App::DBBrowser;

use Encode::Locale;

binmode STDIN,  ':encoding(console_in)';
binmode STDOUT, ':encoding(console_out)';
binmode STDERR, ':encoding(console_out)';

BEGIN {
    print hide_cursor();
    $ENV{TC_RESET_AUTO_UP} = 0;
    if ( $^O eq 'MSWin32' ) {
        require Win32::Console::ANSI;
        print "\e(U";
    }
}

END {
    delete $ENV{TC_RESET_AUTO_UP};
    print clear_to_end_of_screen();
    print show_cursor();
}


my $db_browser = App::DBBrowser->new();
$db_browser->run();


__END__

=pod

=encoding UTF-8

=head1 NAME

C<db-browser> - Browse SQL databases and their tables interactively.

=head1 VERSION

Version 2.440

=head1 BACKWARD INCOMPATIBLE CHANGES

=over

=item

Table names and column names are now unquoted by default (see L</Identifiers>).

=item

Saved subqueries are saved now at plugin level instead at driver level.

=item

How plugin and database configuration data is saved has changed.

=back

=head1 SYNOPSIS

    db-browser -h|--help

    db-browser

    db-browser database, ...

When the C<db-browser> is called with the argument C<-h|--help>, it displays a menu. The menu entry I<Help> shows this
documentation - see L</OPTIONS>.

If C<db-browser> is called without arguments, the user can choose from the databases offered by the database plugin.

If C<db-browser> is called with arguments, those arguments are treated as the list of available databases (or as
available ODBC data sources when using the DBD::ODBC driver).

=head2 SQLite/Firebird

    db-browser -s|--search

Calling C<db-browser> with C<-s|--search> initiates a new search for databases instead of using cached data.

=head1 DESCRIPTION

Before using C<db-browser>, ensure you have backed up your databases.

Search and read in SQL databases: one can interactively browse databases and their tables.

C<App::DBBrowser> provides and supports plugins for the DBI drivers C<DBD::SQLite>, C<DBD::mysql>, C<DBD::MariaDB>,
C<DBD::Pg>, C<DBD::Firebird>, C<DBD::DB2>, C<DBD::Informix>, C<DBD::Oracle> and C<DBD::ODBC>. Refer to
L<App::DBBrowser::DB> for guidance on writing a database plugin.

=head1 NAVIGATION

=head2 Menus

=over

=item *

Use the C<Arrow> keys (or C<h,j,k,l>) to move up and down and to move right or left.

=item *

Press the C<PageUp> key (or C<Ctrl-P>) to go to the previous page and the C<PageDown> key (or C<Ctrl-N>) to go to the
next page.

=item *

Press the C<Home> key (or C<Ctrl-A>) to jump to the beginning of the menu and the C<End> key (or C<Ctrl-E>) to jump to
the end of the menu.

=back

When the I<mouse> option is enabled, you can use the left mouse key to navigate through the menus.

To confirm a chosen menu item, use the C<Return> key.

In some submenus, it is possible to select more than one item before pressing C<Return> (e.g., the input filters
I<Choose Rows> and I<Choose Cols>); in such submenus, the list of items marked with the C<SpaceBar> is added to the
chosen items when C<Return> is pressed. If the mouse mode is enabled, you can use the right mouse key instead of the
C<SpaceBar>. Pressing C<Ctrl-SpaceBar> inverts the made choices - for example, to select all but one, select the one
with the C<SpaceBar> and then press C<Ctrl-SpaceBar>.

=head2 Read-line

=over

=item *

Use C<BackSpace> or C<Strg-H> to delete the character behind the cursor and C<Delete> to delete the character at the
cursor.

=item *

Press C<Strg-U> to delete the text backward from the cursor to the beginning of the line and C<Strg-K> to delete the
text from the cursor to the end of the line.

=item *

Use C<Right-Arrow> to move forward a character and C<Left-Arrow> to move back a character.

=item *

Press C<Page-Up> to move back 10 characters and C<Page-Down> to move forward 10 characters.

=item *

Use C<Home> or C<Strg-A> to move to the start of the line and C<End> or C<Strg-E> to move to the end of the line.

=back

Some C<read-line>s have predefined values. You can access these values with the C<Up-Arrow> and C<Down-Arrow> keys.

To exit a C<read-line> without returning anything, press C<Ctrl-X>. When the input buffer is empty and C<Enter> is
pressed, C<read-line> returns an empty string.

=head1 OUTPUT

The elements are right-justified if they look like a number; otherwise, they are left-justified.

If the option I<squash_spaces> is enabled, leading and trailing spaces are removed from the elements, and spaces are
squashed to a single white space.

Tab characters (C<\t>) are replaced with a space.

Vertical spaces (C<\v>) are squashed to two spaces.

Control characters, code points of the surrogate ranges and non-characters are removed.

See also the option group L</Output>.

C<Ctrl-F> opens a prompt. A regular expression is expected as input. This enables one to display only rows where at
least one column matches the entered pattern. See option L</Search>.

=head1 MENUS

=head2 Plugins Menu

Choosing a plugin leads to the I<Databases Menu>.

(If there is only one plugin, the plugins menu is not shown, but the plugin is chosen automatically.)

=head2 Databases Menu

Choosing a database leads to the I<Schemas Menu>.

(If there is only one database, the databases menu is not shown, but the database is chosen automatically.)

=head2 Schemas Menu

Choosing a schema leads to the I<Tables Menu>.

(If there is not more than one schema, the schemas menu is not shown, but the schema is chosen automatically.)

=head2 Tables Menu

bin/db-browser  view on Meta::CPAN


=head3 Binary Filter

Set I<Binary filter> to C<NO>, C<BNRY>, or C<Hexadecimal>.

C<NO> - print the binary data as it is

C<BNRY> - "BNRY" is printed instead of the binary data

C<Hexadecimal> - the binary data is printed in hexadecimal format

If the first 100 characters of the data match the regexp C</[\x00-\x08\x0B-\x0C\x0E-\x1F]/>, the data is considered
arbitrary binary data.

Printing unfiltered arbitrary binary data could break the output.

=head3 Squash Spaces

If I<squash_spaces> is enabled, consecutive spaces are squashed to one space, and leading and trailing spaces are
removed.

=head3 Undef String

Set the string that will be shown on the screen instead of an undefined field.

On C<MSWin32>, only single-byte character sets are supported when entering the setting I<Undef string>, I<user>,
I<host>, or I<port> with the C<db-browser>'s readline. However, it is possible to edit the entry in configuration files
directly after the entry was created with this options menu.

=head3 Color

Enable support for color and text formatting escape sequences (SGR) by setting it to C<Enable>. Before the output, a
reset (C<\e[0m>) is added at the end of each row.

=head3 Truncate Fractions First

If the terminal width is insufficient and I<Trunc fract first> is enabled, the first step to reduce the column width is
to truncate the fraction part of numbers to 2 decimal places.

=head3 Indentation

Set the indentation width for the SQL substatements.

=head3 Pad row edges

Add a space at the beginning and end of each table row.

=head3 Tab Width

Set the number of spaces between columns.

=head3 Expand Table Rows

Expand table rows:

=over

=item C<YES>

If C<Return> is pressed, the selected table row is printed with each column in its line. The first row is not expanded
if the cursor auto-jumped to the first row.

=item C<NO>

Don't expand table rows.

=back

=head3 Expanded rows line spacing

Insert a blank line between columns when a row is expanded. See option L</Expand Table>.

=head3 Expanded rows max width

Set a maximum width of the expanded table row output. I<Expanded rows max width> set to C<0> means no maximum width. See
option L</Expand Table>.

=head3 Column Trim Threshold

Columns with a width below or equal to I<Column trim threshold> are only trimmed if it is still necessary to reduce the
row width, even after all columns wider than I<Column trim threshold> have been trimmed to I<Column trim threshold>.

=head3 DB2 Encoding

For C<DB2> databases only: set the application code set.

Data from a DB2 database is decoded using this encoding.

=head2 Import Data

=head3 Parse Tool

Set how to parse text files. Files for which C<-T $filename> returns true are considered text files. If a file isn't a
text file, C<Spreadsheet::Read> is always used to parse it, regardless of this setting.

=over

=item

Text::CSV

Advantages:

=over

=item

Allows different CSV-related options.

=item

Speed

=back

=back

=over

=item



( run in 0.678 second using v1.01-cache-2.11-cpan-39bf76dae61 )