pgcmd is a non-interactive PostgreSQL query tool designed for use from the command line. Version 1.2.0 (current stable) outputs results in JSON by default, making them pipeable to tools like jq, and also supports CSV output. It is released under the MIT license with a low release cadence (last update 2020). Key differentiators: minimal dependencies, simple CLI, and supports parameterized queries via -m options. Compared to psql, it offers machine-friendly output with no interactive features.
npm install pgcmdNo compatibility data collected yet for this library.
Runs a parameterized SELECT query against a PostgreSQL database and outputs JSON.
Use environment variables (PGPASSWORD) instead of -p option.
Upgrade pgcmd to v1.1+ or use Node 14+.
Check the JSON output array length or use --csv with headers.
Upgrade to v1.1+ to use --csv.
Use $N for positional parameters.
Install globally: npm install -g pgcmd
Ensure PostgreSQL is running on localhost:5432 or use -h and -p to specify correct host and port.
Use correct password via -p or PGPASSWORD environment variable, or verify user exists.
No dependency data recorded yet.