NAME
pmsql - interactive shell with readline for msql
SYNOPSIS
pmsql [-h host] [database]
DESCRIPTION
pmsql lets you talk to a running msql daemon sending either SQL queries or relshow commands. The output is formatted much in the same way as by the msql monitor (see below) and the relshow program, which are both coming with msql. The additional capability is a connection to a readline interface (if available) and a pipe to your favorite pager. Additionally you may switch between hosts and databases within one session and you don't have to type the nasty \g
(a trailing \g
, \q
, and \p
will be ignored).
If a command starts with one of the following reserved words, it's treated specially, otherwise it is passed on verbatim to the mSQL daemon. Output from the daemon is piped to your pager specified by either the PMSQL_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, the program writes to unfiltered STDOUT.
?
-
print usage summary and current host and database
ho[st] host
-
Set default host to "host"
da[tabase] database
-
Set default database to "database"
re[lshow] [-h host] [database] [table] [index]
-
Describe databases or tables in the same way as done by the relshow program. If host or database are specified, the defaults are set to these values. The prameter
index
is only supported for mSQL-2.0. ! EXPR
-
Eval the EXPR in perl
q[uit]
-
Leave pmsql
Global Variable
The global variable $Q
is used for the statement handle of the current query. You can use this variable in eval statements.
There's no global variable for the database connection, because we connect to the database for each command separately.
Completion
pmsql 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 host or database 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.
BUGS
pmsql is not an msql clone. If you use it as such for bulk uploads into the database, you will notice an enourmous disadvantage in performance. The reason is that pmsql intentionally disconnects from the database after every query.
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 Mysql, Term::ReadKey, Term::ReadLine.