Jochen Wiedmann > Msql-Mysql-modules > dbimon

Download:
Msql-Mysql-modules-1.2219.tar.gz

Annotate this POD

CPAN RT

New  2
Open  1
View/Report Bugs
Source  

NAME ^

dbimon - interactive shell with readline for DBI

SYNOPSIS ^

dbimon <dsn> [<user> [<password>]] [<options>]

DESCRIPTION ^

dbimon lets you talk to a running SQL server via the database independent Perl interface DBI. dbimon was inspired by Andreas Koenig's pmsql and borrows both design ideas and code from it. Thus the look and feel is almost identical to pmsql, in particular the following holds:

If a command starts with one of the following reserved words, it's treated specially, otherwise it is passed on verbatim to the DBMS. Output from the daemon is piped to your pager specified by either the DBIMON_PAGER or the PAGER environment variable. If both are undefined, the PATH is searched for either "less" or "more" and the first program found is taken. If no pager can be determined or your pager variable is empty or set to stdout, the program writes to unfiltered STDOUT.

?

print usage summary

dsn <dsn>

Connects to the given <dsn>, the old connection is closed.

q[uit]

Leave dbimon.

re[lshow] [<dsn> [<table>]]

Without arguments this lists possible data sources by calling DBI's data_sources method. Data sources are driver dependent, the driver of the last connection will be used. Unfortunately DBI offers no possibilities of specifying a hostname or similar dsn attributes, so you can hardly list a remote hosts dsns, for example.

If a dsn is given, dbimon will connect to the given dsn and list its tables. If both dsn and table are present, dbimon will list the tables fields.

The latter possibilities are not supported by the DBI - these work with private methods. Currently they are implemented for DBD::mSQL and DBD::mysql.

se[t] [<var> [<val>]]

This command displays and modifies dbimon's internal variables. Without arguments, all variables and their current settings are listed. With a variable name only you query the variables value. The two argument form modifies a variable. Supported variables are:

showMode

This variable controls the output of an SQL result table. Possible values are Box, Export, List, Table and HTML. These correspond to modes of the Data::ShowTable module with the exception of Export: This is handled by dbimon internally, as Data::ShowTable doesn't offer such a mode. The Export mode is well suited for exporting data to other database systems. See Data::ShowTable(3).

less

This is the pager variable. You can turn off paging by setting this to 'stdout'.

listWrapMargin
maxTableWidth
noEscape

These correspond to the variables $List_Wrap_Margin, $Max_Table_Width and $No_Escape of the Data::ShowTable module. See Data::ShowTable(3).

escapeChar
quoteChar
sepChar

For Export mode dbimon will use these variables. Columns are surrounded by the quoteChar, separated by the sepChar and the escapeChar is used for inserting these special characters. The defaults are well suited for Excel (escapeChar = ", quoteChar = " and sepChar = ;), thus a row with the values 1, 'walrus' and 'Nat "King" Cole' will be displayed as

  "1";"walrus";"Nat ""King"" Cole"
! EXPR

Eval the EXPR in perl

Dumping a database contents

The option --dump forces dump of a databases contents, much like msqldump or mysqldump do. By default all tables are dumped, but you can override this with a sequence of --table $table options.

Dumping means to emit a

    CREATE TABLE $table (...)

statement (unless the option --no-dump-structure is given), followed by a sequence of

    INSERT INTO $table (...)

statements, one per row, unless you use the option --no-dump-data. By default INSERT statements don't include column names, but the option --dump-names can force that.

Completion

dbimon comes with some basic completion definitions that are far from being perfect. Completion means, you can use the TAB character to run some lookup routines on the current dsn or table and use the results to save a few keystrokes.

The completion mechanism is very basic, and I'm not intending to refine it in the near future. Feel free to implement your own refinements and let me know, if you have something better than what we have here.

SEE ALSO ^

You need a readline package installed to get the advantage of a readline interface. If you don't have it, you won't be able to use the arrow keys in a meaningful manner. Term::ReadKey and Term::ReadLine do not come with the perl distribution but are available from CPAN (see http://www.perl.com/CPAN).

See "pmsql (1)", "DBI (3)", "Term::ReadKey (3)", "Term::ReadLine (3)",

syntax highlighting: