pg-cmd » Use cases » Shell scripts
Download pg-cmd Free Trial » Buy pg-cmd Now »
Half of the work with a database is not interactive at all: a nightly import from a feed, a weekly export for a report, a check that runs after a deployment, a migration step in a pipeline. Those jobs have to run in a script, on a schedule, without a terminal and without a person.
An interactive client is the wrong shape for that - and so is a tool whose only interface is a screen.
pg-cmd dsn="user:pass@host:5432/db" task=load table=media datafile=data.txt filetype=txt delimiter=, quote=" header=y quit=ytask=unload and an output file.
The result of a task can be kept as a file and inspected afterwards, which is what makes a scripted job auditable: the log says what was read and what was written, and the exit status tells the caller whether to continue. The same command works on Windows, Linux and macOS - see the same commands everywhere.
The modes: batch mode, scripts, interactive mode. The result file: viewing results. Moving data: JSON and CSV, load, unload. On a server with nothing installed: portable copy.