GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  DBI::SHELL (3)

.ds Aq ’

NAME

DBI::Shell - Interactive command shell for the DBI

CONTENTS

SYNOPSIS



  perl -MDBI::Shell -e shell [<DBI data source> [<user> [<password>]]]



or



  dbish [<DBI data source> [<user> [<password>]]]
  dbish --debug [<DBI data source> [<user> [<password>]]]
  dbish --batch [<DBI data source> [<user> [<password>]]] < batch file



DESCRIPTION

The DBI::Shell module (and dbish command, if installed) provide a simple but effective command line interface for the Perl DBI module.

DBI::Shell is very new, very experimental and very subject to change. Your mileage will vary. Interfaces will change with each release.

TO DO

Proper docs - but not yet, too much is changing.

source file command to read command file. Allow to nest via stack of command file handles. Add command log facility to create batch files.

Commands:

Use Data::ShowTable if available.

Define DBI::Shell plug-in semantics.
        Implement import/export as plug-in module

Clarify meaning of batch mode

Completion hooks

Set/Get DBI handle attributes

Portability

Emulate popular command shell modes (Oracle, Ingres etc)?

ARGUMENTS

debug dbish --debug   enable debug messages
batch dbish --batch < batch_file

COMMANDS

Many commands - few documented, yet!
help


  help



chistory


  chistory          (display history of all commands entered)
  chistory | YourPager (display history with paging)



clear


  clear             (Clears the current command buffer)



commit


  commit            (commit changes to the database)



connect


  connect           (pick from available drivers and sources)
  connect dbi:Oracle (pick source from based on driver)
  connect dbi:YourDriver:YourSource i.e. dbi:Oracle:mysid



Use this option to change userid or password.

count


        count table1 [...]



Run a select count(*) from table on each table listed with this command.

current


  current            (Display current statement in the buffer)



do


  do                 (execute the current (non-select) statement)

        dbish> create table foo ( mykey integer )
        dbish> /do

        dbish> truncate table OldTable /do (Oracle truncate)



drivers


  drivers            (Display available DBI drivers)



edit


  edit               (Edit current statement in an external editor)



Editor is defined using the environment variable $VISUAL or $EDITOR or default is vi. Use option editor=new editor to change in the current session.

To read a file from the operating system invoke the editor (edit) and read the file into the editor buffer.

exit


  exit              (Exits the shell)



get


        get                     Retrieve a previous command to the current buffer.

        get 1                   Retrieve the 1 command executed into the current
                                        buffer.

        get -1         Retrieve the second to last command executed into
                                        the current buffer.



go


  go                (Execute the current statement)



Run (execute) the statement in the current buffer. This is the default action if the statement ends with /



        dbish> select * from user_views/

        dbish> select table_name from user_tables
        dbish> where table_name like DSP%
        dbish> /

        dbish> select table_name from all_tables/ | more



history


  history            (Display combined command and result history)
  history | more



load


  load file name    (read contains of file into the current buffer)



The contains of the file is loaded as the current buffer.

option


  option [option1[=value]] [option2 ...]
  option            (Displays the current options)
  option   MyOption (Displays the value, if exists, of MyOption)
  option   MyOption=4 (defines and/or sets value for MyOption)



perl


  perl               (Evaluate the current statement as perl code)



quit


  quit               (quit shell.  Same as exit)



redo


  redo               (Re-execute the previously executed statement)



rhistory


  rhistory           (Display result history)



rollback


  rollback           (rollback changes to the database)



For this to be useful, turn the autocommit off. option autocommit=0

run


  run file name      (load and execute a file.)



This commands load the file (may include full path) and executes. The file is loaded (replaces) the current buffer. Only 1 statement per file is allowed (at this time).

save


  save file name    (write contains of current buffer to file.)



The contains of the current buffer is written to file. Currently, this command will overwrite a file if it exists.

spool


  spool file name  (Starts sending all output to file name)
  spool on         (Starts sending all output to on.lst)
  spool off        (Stops sending output)
  spool            (Displays the status of spooling)



When spooling, everything seen in the command window is written to a file (except some of the prompts).

table_info


  table_info         (display all tables that exist in current database)
  table_info | more  (for paging)



trace


  trace              (set DBI trace level for current database)



Adjust the trace level for DBI 0 - 4. 0 off. 4 lots of information. Useful for determining what is really happening in DBI. See DBI.

type_info


  type_info          (display data types supported by current server)



CONFIGURATION

The configuration file (~/.dbish_config by default, overridden by $DBISH_CONFIG) is eval’d as perl code and should return a hash ref containing the configuration items. Notable keys include
options The value is another hashref containing the options and their values. Type /option at the prompt to get a list of acceptable options.
plug-ins Plugins to load. This is a rather complex data structure which is recursively walked to determine which plugins should be loaded. At the top level, there are the phases pre-init, post-init, pre-connect, and post-connect. At lower levels plugins can be selected by the name of the database driver, and individual options can be set. Finally, at some point an arrayref containing the package names of the plugins to load must be found.
Since the config file can contain arbitrary perl code, it can do anything which can be done in perl. One rather useful hack is to call binmode to set the encoding for standard input and output.

    Example



    binmode STDIN,  ":utf8";
    binmode STDOUT, ":utf8";

    {
        options => {
            format => partbox,
        },
        plug-ins => {
            pre-init => [
                DBI::Shell::Timing,
                DBI::Shell::Spool,
            ],
        },
    };



This config file first sets the :utf8 layer for input and output to match the terminal (if you don’t use UTF-8, you could use :encoding() here), and then returns the hashref with the configuration items: The format is set ’partbox’, and the the two plugins ’DBI::Shell::Timing’ and ’DBI::Shell::Spool’ are loaded.

ENVIRONMENT

DBISH_TMP Where to write temporary files.
DBISH_CONFIG Which configuration file used. Unset to not read any additional configurations.

AUTHORS and ACKNOWLEDGEMENTS

The DBI::Shell has a long lineage.

It started life around 1994-1997 as the pmsql script written by Andreas Koenig. Jochen Wiedmann picked it up and ran with it (adding much along the way) as dbimon, bundled with his DBD::mSQL driver modules. In 1998, around the time I wanted to bundle a shell with the DBI, Adam Marks was working on a dbish modeled after the Sybase sqsh utility.

Wanting to start from a cleaner slate than the feature-full but complex dbimon, I worked with Adam to create a fairly open modular and very configurable DBI::Shell module. Along the way Tom Lowery chipped in ideas and patches. As we go further along more useful code and concepts from Jochen’s dbimon is bound to find it’s way back in.

COPYRIGHT

The DBI::Shell module is Copyright (c) 1998 Tim Bunce. England. All rights reserved. Portions are Copyright by Jochen Wiedmann, Adam Marks and Tom Lowery.

You may distribute under the terms of either the GNU General Public License or the Artistic License, as specified in the Perl README file.

POD ERRORS

Hey! <B>The above document had some coding errors, which are explained below:B>
Around line 1939: Non-ASCII character seen before =encoding in ’Koenig.’. Assuming ISO8859-1
Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 DBI::SHELL (3) 2008-02-14

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.