Jochen Wiedmann > Msql-Mysql-modules > pmsql

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

Annotate this POD

CPAN RT

New  2
Open  1
View/Report Bugs
Source  

NAME ^

pmsql, pmysql - interactive shells with readline for msql and mysql

SYNOPSIS ^

pmsql [-h host] [database]

or

pmysql [-h host] [database]

DESCRIPTION ^

pmsql and pmysql let you talk to a running msql or mysql daemon sending either SQL queries or relshow (mysqlshow) commands. The output is formatted much in the same way as by the msql or mysql monitor (see below), the msqlexport command and the relshow (mysqlshow) program, which are coming with msql or mysql. 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 or ; (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 or mysql daemon. Output from the daemon is piped to your pager specified by either the PMSQL_PAGER (PMYSQL_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 contains the word stdout, the program writes to unfiltered STDOUT.

?

print usage summary and current host and database

da[tabase] database

Set default database to "database"

e[scape]

Set the escape character which is used when fancy mode is off. Defaults to ".

f[ancy] on|off

Set the output format of SELECT commands, default is on. A value of off will create output suitable for export to other database systems. The non-fancy output format is configurable with the commands escape, quote and separator, the default is well suited for import into Microsoft Ecxel.

ho[st] host

Set default host to "host"

q[uit]

Leave pmsql or pymsql

quo[te]

Set the quote character which is used when fancy mode is off. Defaults to ".

re[lshow] [-h host] [database] [table] [index]

Describe databases or tables in the same way as done by the relshow (mysqlshow) program. If host or database are specified, the defaults are set to these values. The prameter index is only supported for mSQL-2.0.

s[eparator]

Set the quote character which is used when fancy mode is off. Defaults to ,.

! EXPR

Eval the EXPR in perl

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 and pmysql come 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 and pmysql are not an msql and mysql clones. 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 and pmysql intentionally disconnect 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 Msql, Mysql, Term::ReadKey, Term::ReadLine.

syntax highlighting: