{"id":14973867,"url":"https://github.com/soheilpro/pgcmd","last_synced_at":"2025-10-27T02:31:36.438Z","repository":{"id":53412311,"uuid":"203624331","full_name":"soheilpro/pgcmd","owner":"soheilpro","description":"Non-interactive PostgreSQL query tool.","archived":false,"fork":false,"pushed_at":"2022-12-08T15:39:14.000Z","size":16,"stargazers_count":117,"open_issues_count":0,"forks_count":8,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-09-28T18:05:03.839Z","etag":null,"topics":["postgres","postgresql","psql"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/soheilpro.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-08-21T16:34:15.000Z","updated_at":"2024-01-04T16:36:59.000Z","dependencies_parsed_at":"2023-01-25T07:46:44.235Z","dependency_job_id":null,"html_url":"https://github.com/soheilpro/pgcmd","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soheilpro%2Fpgcmd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soheilpro%2Fpgcmd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soheilpro%2Fpgcmd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soheilpro%2Fpgcmd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/soheilpro","download_url":"https://codeload.github.com/soheilpro/pgcmd/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219861968,"owners_count":16555980,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["postgres","postgresql","psql"],"created_at":"2024-09-24T13:49:36.444Z","updated_at":"2025-10-27T02:31:36.100Z","avatar_url":"https://github.com/soheilpro.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pgcmd\nNon-interactive PostgreSQL query tool.\n\nBy default, it outputs JSON which means that you can process and view the results with tools like [jq](https://stedolan.github.io/jq/manual) or [catj](https://github.com/soheilpro/catj).\n\n## Install\n\n```\nnpm install -g pgcmd\n```\n\n## Usage\n```\npgcmd -h localhost \\\n      -u postgres \\\n      -p p@ssw0rd \\\n      -d postgres \\\n      'select * from pg_database where datname = $1' \\\n      -m template0\n```\n\nIf no script is specified, pgcmd reads from the standard input:\n\n```\necho 'select * from pg_database where datname = $1' | pgcmd -m template0\n```\n\nOutput:\n```\n[\n  {\n    \"datname\": \"template0\",\n    \"datdba\": 10,\n    \"encoding\": 6,\n    \"datcollate\": \"en_US.utf8\",\n    \"datctype\": \"en_US.utf8\",\n    \"datistemplate\": true,\n    \"datallowconn\": false,\n    \"datconnlimit\": -1,\n    \"datlastsysoid\": 13066,\n    \"datfrozenxid\": \"562\",\n    \"datminmxid\": \"1\",\n    \"dattablespace\": 1663,\n    \"datacl\": \"{=c/postgres,postgres=CTc/postgres}\"\n  }\n]\n```\n\nIt can also output CSV:\n\n```\npgcmd 'select * from pg_database' --csv\n```\n\nOutput:\n```\ndatname,datdba,encoding,datcollate,datctype,datistemplate,datallowconn,datconnlimit,datlastsysoid,datfrozenxid,datminmxid,dattablespace,datacl\npostgres,10,6,en_US.utf8,en_US.utf8,,1,-1,13066,562,1,1663,\ntemplate1,10,6,en_US.utf8,en_US.utf8,1,1,-1,13066,562,1,1663,\"{=c/postgres,postgres=CTc/postgres}\"\ntemplate0,10,6,en_US.utf8,en_US.utf8,1,,-1,13066,562,1,1663,\"{=c/postgres,postgres=CTc/postgres}\"\n```\n\n## Environment Variables\nThe following environment variables are supported:\n- PGHOST\n- PGPORT\n- PGUSER\n- PGPASSWORD\n- PGDATABASE\n\n## Version History\n+ **1.2**\n  + Removed the default timeout.\n+ **1.1**\n  + Added `--csv` output option.\n  + Added support for Node 14. (Thanks [darky](https://github.com/darky))\n  + Set exit code on errors. (Thanks [darky](https://github.com/darky))\n+ **1.0**\n\t+ Initial release.\n\n## Author\n**Soheil Rashidi**\n\n+ http://soheilrashidi.com\n+ http://twitter.com/soheilpro\n+ http://github.com/soheilpro\n\n## Copyright and License\nCopyright 2020 Soheil Rashidi.\n\nLicensed under the The MIT License (the \"License\");\nyou may not use this work except in compliance with the License.\nYou may obtain a copy of the License in the LICENSE file, or at:\n\nhttp://www.opensource.org/licenses/mit-license.php\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoheilpro%2Fpgcmd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsoheilpro%2Fpgcmd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoheilpro%2Fpgcmd/lists"}