db-browser - Search and read in SQLite/MySQL/PostgreSQL databases.
db-browser
Version 0.024
db-browser db-browser -h|--help
When the db-browser is called with the argument -h|--help it shows a menu - see "OPTIONS".
-h|--help
db-browser [-s|--search] [directories to be searched]
If no directories are passed the home directory is searched for SQLite databases.
db-browser called with -s|--search causes a new search of SQLite databases instead of using the cached data.
-s|--search
Search and read in SQLite/MySQL/PostgreSQL databases.
To be able to browse database-, schema- and table-lists and the content of tables one needs to have the database privileges required for fetching the respective data.
The db-browser expects an existing home directory with read and write permissions for the user of the db-browser.
It is recommended to work with an UTF encoding. Non mappable characters might break the output.
It is required a terminal with a width of at least 40 print columns.
Before the output leading and trailing spaces are removed from the elements and spaces are squashed to a single white-space.
The elements in a column are right-justified if one or more elements of that column do not look like a number, else they are left-justified.
See Term::TablePrint for more details.
The best way to find out how db-browser works is calling db-browser.
To be able to use all the features of the db-browser some basic SQL knowledge is required.
the Arrow keys (or h,j,k,l) to move up and down and to move to the right and to the left,
Arrow
h,j,k,l
the PageUp key (or Ctrl-B) to go back one page, the PageDown key (or Ctrl-F) to go forward one page.
PageUp
Ctrl-B
PageDown
Ctrl-F
the Home key (or Ctrl-A) to jump to the beginning of the menu, the End key (or Ctrl-E) to jump to the end of the menu.
Home
Ctrl-A
End
Ctrl-E
the Enter/Return key to confirm a chosen menu item.
Enter/Return
With the option mouse mode enabled it can be used the mouse with the left mouse key to navigate through the menus.
The q key goes back (Ctrl-D instead of q if prompted for a string) in the menu hierarchy.
q
Ctrl-D
Show this Info.
Shows the version and the path of the running db-browser and the path of the application directory.
Columns with a width below or equal Colwidth are only trimmed if it is still required to lower the row width despite all columns have been trimmed to Colwidth.
Set Database defaults:
If set to "YES" DBD::SQLite tries to see if the bind values are numbers or not, and does not quote if they are numbers.
See DBD::SQLite for details. This is a SQLite-only option.
If enabled the utf8 flag will be turned on for character data coming from the database.
For a more driver specific explanation see the documentation of the respective Perl DBI driver.
With the Pg driver in use it is available - apart from the "YES/NO" choices - also an "AUTO" choice. If the DBD::Pg version is less than 3.0.0 "AUTO" is mapped to "YES". For the meaning of "AUTO" look in pg_enable_utf8 for the value -1.
Pg
Print "BNRY" instead of arbitrary binary data.
If the data matches the repexp /[\x00-\x08\x0B-\x0C\x0E-\x1F]/ it is considered arbitrary binary data.
/[\x00-\x08\x0B-\x0C\x0E-\x1F]/
Printing arbitrary binary data could break the output.
DB Defaults can be overwritten for each Database with the Database menu entry "Database settings".
Choose the required database drivers.
Determine when db-browser asks for the login data:
- per-DB: log in data is asked once per database.
- once: log in data is asked only once and then used for all connections.
This option has no meaning if the SQLite driver is in use.
- use DBI_USER as username for all database logins.
DBI_USER
- use DBI_PASS as password for all database logins.
DBI_PASS
Set the behavior of different menus.
For the menus "Choose Database", "Choose Schema" and "Choose Table" setting Expand to "Enchanted" means: save the menu position.
For "Print Table" "Enchanted" means: enable printing the chosen table row.
Set the default lock value:
- Lk0: Reset the SQL-statement after each "PrintTable".
- Lk1: Reset the SQL-statement only when a table is selected.
Set the maximum number of fetched table rows. This can be overwritten by setting a SQL LIMIT statement.
LIMIT
The fetched table rows are kept in memory.
To disable the automatic limit set max rows to 0.
If enabled system tables/schemas/databases are appended to the respective list.
Set the mouse mode (see "mouse" in Term::Choose).
Choose the required operators.
Enable parentheses in WHERE and/or HAVING TO clauses.
WHERE
HAVING TO
Set the progress bar threshold. If the number of fields (rows x columns) is higher than the threshold a progress bar is shown while preparing the data for the output.
If enabled REGEXP will match case sensitive.
REGEXP
With MySQL the sensitive match is achieved by enabling the BINARY operator.
BINARY
With the Sssc mode "compat" enabled back-arrows are offered in the SQL menus entries. In the "simple" mode it can be used the q key instead of the back-arrows.
Set the number of spaces between columns.
Set the string that will be shown on the screen instead of an undefined field.
The following hints refer to the SQL menu - the menu which opens after a table was selected.
If AGGREGATE or/and GROUP BY is set, the SELECT statement is automatically formed.
AGGREGATE
GROUP BY
SELECT
To reset a SQL "sub-statement" (e.g WHERE) re-enter into the respective menu entry and choose '- OK -'.
'- OK -'
Changing the lock mode (Lk0,Lk1) will also reset the entire SQL.
There is a hidden menu entry: selecting the prompt Customize: makes available some scalar functions:
With SQLite the function TRUNCATE is a user defined function which returns stringified values.
TRUNCATE
When comparing in WHERE or HAVING TO clauses with numbers take the non-truncated (original) value for the comparison if sqlite_see_if_its_a_number is enabled (default).
sqlite_see_if_its_a_number
Also to get a numeric comparison in an ORDER BY clause use the non-truncated (original) values for the ordering.
ORDER BY
With SQLite the function Bit_Length is a user defined function which uses the Perl builtin length. To make length return the number of bytes the bytes pragma is used.
Bit_Length
length
bytes
use
With SQLite the function Char_Length is a user defined function which uses the Perl builtin length to get the number of characters.
Char_Length
To remove a chosen scalar function from a column select the column with the function a second time.
In the COLUMNS and GROUP BY menu it is possibly to select more columns at once with the SpaceBar or the right mouse key if the mouse mode is enabled.
SpaceBar
Matthäus Kiem <cuer2s@gmail.com>
Thanks to the Perl-Community.de and the people form stackoverflow for the help.
Copyright 2012-2014 Matthäus Kiem.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl 5.10.0. For details, see the full text of the licenses in the file LICENSE.
To install App::DBBrowser, copy and paste the appropriate command in to your terminal.
cpanm
cpanm App::DBBrowser
CPAN shell
perl -MCPAN -e shell install App::DBBrowser
For more information on module installation, please visit the detailed CPAN module installation guide.