{"id":43603,"library":"pgcmd","title":"pgcmd","description":"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.","status":"active","version":"1.2.0","language":"javascript","source_language":"en","source_url":"https://github.com/soheilpro/pgcmd","tags":["javascript","postgresql","postgres"],"install":[{"cmd":"npm install pgcmd","lang":"bash","label":"npm"},{"cmd":"yarn add pgcmd","lang":"bash","label":"yarn"},{"cmd":"pnpm add pgcmd","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[],"quickstart":{"code":"pgcmd -h localhost -u postgres -p mypassword -d postgres 'select * from pg_database where datname = $1' -m template0","lang":"javascript","description":"Runs a parameterized SELECT query against a PostgreSQL database and outputs JSON."},"warnings":[{"fix":"Use environment variables (PGPASSWORD) instead of -p option.","message":"Password on command line is visible in process listings and shell history.","severity":"gotcha","affected_versions":">=1.0"},{"fix":"Upgrade pgcmd to v1.1+ or use Node 14+.","message":"Node.js 14 support was added in v1.1 but older Node versions might not work.","severity":"deprecated","affected_versions":"<1.1"},{"fix":"Check the JSON output array length or use --csv with headers.","message":"No output if query returns empty result set. Exit code may not reflect SQL errors correctly in all cases.","severity":"gotcha","affected_versions":">=1.0"},{"fix":"Upgrade to v1.1+ to use --csv.","message":"The --csv option was added in v1.1; previous versions only output JSON.","severity":"breaking","affected_versions":"<1.1"},{"fix":"Use $N for positional parameters.","message":"Parameter placeholders use $1, $2, etc. (like libpq), not ?.","severity":"gotcha","affected_versions":">=1.0"}],"env_vars":null,"search_vec":"'1.2.0':19 '2020':54 'also':36 'cadenc':51 'cli':60 'command':16 'compar':68 'csv':38 'current':20 'default':27 'depend':58 'design':11 'differenti':56 'featur':80 'friend':75 'interact':7,79 'javascript':81 'jq':34 'json':25 'key':55 'last':52 'licens':46 'like':33 'line':17 'low':49 'm':66 'machin':74 'machine-friend':73 'make':28 'minim':57 'mit':45 'non':6 'non-interact':5 'offer':72 'option':67 'output':22,39,76 'parameter':63 'pgcmd':1,2 'pipeabl':30 'postgr':83 'postgresql':8,82 'psql':70 'queri':9,64 'releas':42,50 'result':23 'simpl':59 'stabl':21 'support':37,62 'tool':10,32 'updat':53 'use':13 'version':18 'via':65","created_at":"2026-06-05T17:00:35.930413+00:00","updated_at":"2026-06-05T17:00:35.930413+00:00","problems":[{"fix":"Install globally: npm install -g pgcmd","cause":"pgcmd is not installed or not in PATH.","error":"pgcmd: command not found"},{"fix":"Ensure PostgreSQL is running on localhost:5432 or use -h and -p to specify correct host and port.","cause":"PostgreSQL server is not running or port is blocked.","error":"Error: connect ECONNREFUSED 127.0.0.1:5432"},{"fix":"Use correct password via -p or PGPASSWORD environment variable, or verify user exists.","cause":"Incorrect password or user does not exist.","error":"Error: password authentication failed for user \"postgres\""}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/soheilpro/pgcmd#readme","github":"https://github.com/soheilpro/pgcmd","docs":null,"changelog":null,"pypi":null,"npm":"pgcmd","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-05","next_check":"2026-09-03","install_tag":null}}