Next: Procedure Index, Previous: Introspection, Up: Top
Sometimes you just want to poke around manually, interacting with a database connection by typing in exploratory commands, and the external command-line program psql(1) does not provide enough insight or customizability (or perhaps is not available). This chapter presents an alternative method for running such a repl (read-eval-print loop).
To get started, load the postgres-gxrepl module:
(use-modules (database postgres-gxrepl))
This provides the procedure gxrepl. The “gx” stands for “guile
extensible”, which is not the case at the moment, but we have great and
humble plans for this module...
[NOTE: docs missing for gxrepl]
Most comma commands are relatively self-explanatory, with guidance from
,help. The rest of this chapter delves into some of the more
arcane commands.
Primarily, the fixed-part select is an exploratory type of interaction
where you can fix certain parts of a normal select query so that
you can concentrate on varying the rest.
For example:
,fix #:from icbmcoords
Use the table `icbmcoords' (with columns `one', `two' and `importance').
,fsel one two #:where (< 9 importance)
Select some tuples.
,fix #:cols ("latitude" . one) ("longitude" . two)
More descriptive titles.
,fix #:where (< 9 importance) (> 3 importance)
We are scatterbrained, which helps ameliorate the evilness.
,fix #:where/combiner or
Uh oh, wits recovered, we once again are a menace.
For comparison, here is the last example again, recast into SQL:
SELECT one AS "latitude", two AS "longitude"
FROM icbmcoords
WHERE ((9 < importance) OR (3 > importance));