All Projects → soheilpro → Pgcmd

soheilpro / Pgcmd

Licence: mit
Non-interactive PostgreSQL query tool.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Pgcmd

Testgres
Testing framework for PostgreSQL and its extensions
Stars: ✭ 85 (-27.35%)
Mutual labels:  postgresql, postgres
Pgfe
The PostgreSQL client API in modern C++
Stars: ✭ 98 (-16.24%)
Mutual labels:  postgresql, postgres
Electrocrud
Database CRUD Application Built on Electron | MySQL, Postgres, SQLite
Stars: ✭ 1,267 (+982.91%)
Mutual labels:  postgresql, postgres
Repmgr
A lightweight replication manager for PostgreSQL (Postgres) - latest version 5.2.1 (2020-12-07)
Stars: ✭ 1,207 (+931.62%)
Mutual labels:  postgresql, postgres
Activerecord Clean Db Structure
Automatic cleanup for the Rails db/structure.sql file (ActiveRecord/PostgreSQL)
Stars: ✭ 101 (-13.68%)
Mutual labels:  postgresql, postgres
Sql
MySQL & PostgreSQL pipe
Stars: ✭ 81 (-30.77%)
Mutual labels:  postgresql, postgres
Libpq.jl
A Julia wrapper for libpq
Stars: ✭ 109 (-6.84%)
Mutual labels:  postgresql, postgres
Osmium
Online collaborative fitting tool.
Stars: ✭ 74 (-36.75%)
Mutual labels:  postgresql, postgres
Quiz
Example real time quiz application with .NET Core, React, DDD, Event Sourcing, Docker and built-in infrastructure for CI/CD with k8s, jenkins and helm
Stars: ✭ 100 (-14.53%)
Mutual labels:  postgresql, postgres
Pgcli
Postgres CLI with autocompletion and syntax highlighting
Stars: ✭ 9,985 (+8434.19%)
Mutual labels:  postgresql, postgres
Bgworker
Background Worker Processes for PostgreSQL written in Go
Stars: ✭ 77 (-34.19%)
Mutual labels:  postgresql, postgres
Postgres Checkup
Postgres Health Check and SQL Performance Analysis. 👉 THIS IS A MIRROR OF https://gitlab.com/postgres-ai/postgres-checkup
Stars: ✭ 110 (-5.98%)
Mutual labels:  postgresql, postgres
Plv8
V8 Engine Javascript Procedural Language add-on for PostgreSQL
Stars: ✭ 1,195 (+921.37%)
Mutual labels:  postgresql, postgres
Ship Hold
data access framework for Postgresql on nodejs
Stars: ✭ 110 (-5.98%)
Mutual labels:  postgresql, postgres
Vip Manager
Manages a virtual IP based on state kept in etcd or Consul
Stars: ✭ 75 (-35.9%)
Mutual labels:  postgresql, postgres
Prisma
Next-generation ORM for Node.js & TypeScript | PostgreSQL, MySQL, MariaDB, SQL Server, SQLite & MongoDB (Preview)
Stars: ✭ 18,168 (+15428.21%)
Mutual labels:  postgresql, postgres
Squid
🦑 Provides SQL tagged template strings and schema definition functions.
Stars: ✭ 57 (-51.28%)
Mutual labels:  postgresql, postgres
Rpg Boilerplate
Relay (React), Postgres, and Graphile (GraphQL): A Modern Frontend and API Boilerplate
Stars: ✭ 62 (-47.01%)
Mutual labels:  postgresql, postgres
Node Postgres
PostgreSQL client for node.js.
Stars: ✭ 10,061 (+8499.15%)
Mutual labels:  postgresql, postgres
Pg flame
A flamegraph generator for Postgres EXPLAIN ANALYZE output.
Stars: ✭ 1,391 (+1088.89%)
Mutual labels:  postgresql, postgres

pgcmd

Non-interactive PostgreSQL query tool.

By default, it outputs JSON which means that you can process and view the results with tools like jq or catj.

Install

npm install -g pgcmd

Usage

pgcmd -h localhost \
      -u postgres \
      -p [email protected] \
      -d postgres \
      'select * from pg_database where datname = $1' \
      -m template0

If no script is specified, pgcmd reads from the standard input:

echo 'select * from pg_database where datname = $1' | pgcmd -m template0

Output:

[
  {
    "datname": "template0",
    "datdba": 10,
    "encoding": 6,
    "datcollate": "en_US.utf8",
    "datctype": "en_US.utf8",
    "datistemplate": true,
    "datallowconn": false,
    "datconnlimit": -1,
    "datlastsysoid": 13066,
    "datfrozenxid": "562",
    "datminmxid": "1",
    "dattablespace": 1663,
    "datacl": "{=c/postgres,postgres=CTc/postgres}"
  }
]

It can also output CSV:

pgcmd 'select * from pg_database' --csv

Output:

datname,datdba,encoding,datcollate,datctype,datistemplate,datallowconn,datconnlimit,datlastsysoid,datfrozenxid,datminmxid,dattablespace,datacl
postgres,10,6,en_US.utf8,en_US.utf8,,1,-1,13066,562,1,1663,
template1,10,6,en_US.utf8,en_US.utf8,1,1,-1,13066,562,1,1663,"{=c/postgres,postgres=CTc/postgres}"
template0,10,6,en_US.utf8,en_US.utf8,1,,-1,13066,562,1,1663,"{=c/postgres,postgres=CTc/postgres}"

Environment Variables

The following environment variables are supported:

  • PGHOST
  • PGPORT
  • PGUSER
  • PGPASSWORD
  • PGDATABASE

Version History

  • 1.1
    • Added --csv output option.
    • Added support for Node 14. (Thanks darky)
    • Set exit code on errors. (Thanks darky)
  • 1.0
    • Initial release.

Author

Soheil Rashidi

Copyright and License

Copyright 2020 Soheil Rashidi.

Licensed under the The MIT License (the "License"); you may not use this work except in compliance with the License. You may obtain a copy of the License in the LICENSE file, or at:

http://www.opensource.org/licenses/mit-license.php

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].