Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Does DBI::Shell work for you?

by saintmike (Vicar)
on Mar 05, 2005 at 18:58 UTC ( #436942=perlquestion: print w/ replies, xml ) Need Help??
saintmike has asked for the wisdom of the Perl Monks concerning the following question:

DBI::Shell looks like a cool idea. The manpage says that the module is very experimental, I'm just trying to get a sneak preview.

So, there's a bunch of 'shell' commands like connect, history, exit, etc., but when I start the shell via

    $ dbish

then I get a selection menu of all available DBI drivers. Selecting dbi:mysql gets me a selection of all available mysql databases. Selecting one of them drops me into the shell. However, this 'shell' doesn't understand the commands listed in the man page, but seems to accept SQL commands instead.

On the other hand, starting the shell via

    $ perl -MDBI::Shell -eshell

drops me into a different shell, showing a (not connected)> prompt. After typing in commands, it just returns to the prompt, though.

I must be overlooking something obvious -- has any of you DBI wizards gotten the shell to work and can give advice or (even better) point to a tutorial?

Comment on Does DBI::Shell work for you?
Select or Download Code
Re: Does DBI::Shell work for you?
by rlb3 (Deacon) on Mar 05, 2005 at 19:35 UTC

    Hello,

    I think you need to add a DSN to dbish command.

    Something like:

    dbish dbi:mysql:test

    That may work for you.

Re: Does DBI::Shell work for you?
by jZed (Prior) on Mar 05, 2005 at 20:09 UTC
    DBI::Shell and dbish are great. There's a lot in there although the interfaces is sometimes confusing. The basic thing you're missing, I think is a DSN. Try something along the lines of dbish dbi:DBM: e.g. for using DBD::DBM. Note this should be everthing that normally goes in the DSN, including the colon after the driver name. You can also add user, password and other flags as arguments to dbish, including --batch which runs it in batch mode (e.g. reading a bunch of SQL from a file and executing it).
      Supplying DSN, user and password on the command line as in
      dbish dbi:mysql root ""
      brings up a list of databases, selecting one by number asks for the password again (tsk, tsk!):

      Connecting to 'DBI:mysql:sometable' as 'root'... Password for root ( not echoed to screen):
      which, after confirming it's empty, brings up a shell accepting SQL commands and executing them after entering a semicolon. Very similar to the mysql command line utility.

      But how would I get back out to the previous view, to get the list of databases again? Are there ways other than the native SQL commands (show tables; show columns from tablename) to display the schema(s)? Can I load data into variables and look at them? Guess I'm just confused with the interface. I was expecting more than what a native SQL client provides, guess it's somewhere hidden in there, I'm just not sure how to submit shell commands other than SQL statements, executed as soon as the semicolon gets entered.

        > But how would I get back out to the previous view, to get
        > the list of databases again?
        
        /connect then enter
        >Are there ways other than the native SQL commands
        >(show tables; show columns from tablename) to display
        >the schema(s)?
        
        /col_info /table_info etc. ... type /help and press enter for a list

        > Can I load data into variables and look at them?
        
        Yes, you can, though I forget whether that's something I had to patch.
        >I'm just not sure how to submit shell commands other than 
        > SQL statements, executed as soon as the semicolon gets 
        > entered.
        
        type a forward slash, the command, then press enter
Re: Does DBI::Shell work for you?
by dpavlin (Friar) on Mar 06, 2005 at 15:37 UTC
    My strange problems with dbish (Command 'quit' not recognized) originated from old dbish script which existed in /usr/local/bin/ which was in path before new one. Since it had 2001 timestamp, I guess it was left-over from times when DBI::Shell wasn't separate distribution.

    While this is not exactly same as your problem, i think that hint with which dbish to find out exactly which script are you using helps a lot, so I added it for benefit of monks that find this node with search.
    At one point in time I also had similar problem with cpan (shell).


    2share!2flame...

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://436942]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2014-09-17 03:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (56 votes), past polls