All Projects → NikolayS → Postgres_dba

NikolayS / Postgres_dba

Licence: bsd-3-clause
The missing set of useful tools for Postgres DBAs and all engineers

Projects that are alternatives of or similar to Postgres dba

Libpqxx
The official C++ client API for PostgreSQL.
Stars: ✭ 492 (-7.52%)
Mutual labels:  postgresql, postgres
Labnotebook
LabNotebook is a tool that allows you to flexibly monitor, record, save, and query all your machine learning experiments.
Stars: ✭ 526 (-1.13%)
Mutual labels:  postgresql, postgres
Postgres
PostgreSQL driver for Deno
Stars: ✭ 352 (-33.83%)
Mutual labels:  postgresql, postgres
Epgsql
Erlang PostgreSQL client library.
Stars: ✭ 336 (-36.84%)
Mutual labels:  postgresql, postgres
Check postgres
Nagios check_postgres plugin for checking status of PostgreSQL databases
Stars: ✭ 438 (-17.67%)
Mutual labels:  postgresql, postgres
Pg Boss
Queueing jobs in Node.js using PostgreSQL like a boss
Stars: ✭ 525 (-1.32%)
Mutual labels:  postgresql, postgres
Sqlx
🧰 The Rust SQL Toolkit. An async, pure Rust SQL crate featuring compile-time checked queries without a DSL. Supports PostgreSQL, MySQL, SQLite, and MSSQL.
Stars: ✭ 5,039 (+847.18%)
Mutual labels:  postgresql, postgres
Graphql Starter
💥 Monorepo template (seed project) pre-configured with GraphQL API, PostgreSQL, React, Relay, and Material UI.
Stars: ✭ 3,377 (+534.77%)
Mutual labels:  postgresql, postgres
With advisory lock
Advisory locking for ActiveRecord
Stars: ✭ 409 (-23.12%)
Mutual labels:  postgresql, postgres
Sqlboiler
Generate a Go ORM tailored to your database schema.
Stars: ✭ 4,497 (+745.3%)
Mutual labels:  postgresql, postgres
Zombodb
Making Postgres and Elasticsearch work together like it's 2021
Stars: ✭ 3,781 (+610.71%)
Mutual labels:  postgresql, postgres
Beam
A type-safe, non-TH Haskell SQL library and ORM
Stars: ✭ 454 (-14.66%)
Mutual labels:  postgresql, postgres
Wal E
Continuous Archiving for Postgres
Stars: ✭ 3,313 (+522.74%)
Mutual labels:  postgresql, postgres
Citus
Distributed PostgreSQL as an extension
Stars: ✭ 5,580 (+948.87%)
Mutual labels:  postgresql, postgres
Ansible Role Postgresql
Ansible Role - PostgreSQL
Stars: ✭ 310 (-41.73%)
Mutual labels:  postgresql, postgres
Jet
Type safe SQL builder with code generation and automatic query result data mapping
Stars: ✭ 373 (-29.89%)
Mutual labels:  postgresql, postgres
Loukoum
A simple SQL Query Builder
Stars: ✭ 305 (-42.67%)
Mutual labels:  postgresql, postgres
Yiigo
🔥 Go 轻量级开发通用库 🚀🚀🚀
Stars: ✭ 304 (-42.86%)
Mutual labels:  postgresql, postgres
Deno Nessie
A modular Deno library for PostgreSQL, MySQL, MariaDB and SQLite migrations
Stars: ✭ 381 (-28.38%)
Mutual labels:  postgresql, postgres
Zapatos
Zero-abstraction Postgres for TypeScript: a non-ORM database library
Stars: ✭ 448 (-15.79%)
Mutual labels:  postgresql, postgres

CircleCI

postgres_dba (PostgresDBA)

The missing set of useful tools for Postgres DBA and mere mortals.

⚠️ If you have great ideas, feel free to create a pull request or open an issue.

Demo

👉 See also postgres-checkup, a tool for automated health checks and SQL performance analysis.

Questions?

Questions? Ideas? Contact me: [email protected], Nikolay Samokhvalov.

Credits

postgres_dba is based on useful queries created and improved by many developers. Here is incomplete list of them:

Requirements

You need to have psql version 10 or newer, but the Postgres server itself can be older – most tools work with it. You can install postgresql-client library version, say, 12 on your machine and use it to work with Postgres server version 9.6 and older – in this case postgres_dba will work. But you do need to have psql from the latest (version 12) Postgres release.

On clean Ubuntu, this is how you can get postgresql-client and have the most recent psql:

sudo sh -c "echo \"deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main\" >> /etc/apt/sources.list.d/pgdg.list"
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get install -y postgresql-client-12

Using alternative psql pager called "pspg" is highly recommended (but not required): https://github.com/okbob/pspg.

Installation

The installation is trivial. Clone the repository and put "dba" alias to your .psqlrc file:

git clone https://github.com/NikolayS/postgres_dba.git
echo "\\set dba '\\\\i `pwd`/postgres_dba/start.psql'" >> ~/.psqlrc  # bash version; won't work in zsh

That's it.

Usage

Connect to Local Postgres Server

If you are running psql and Postgres server on the same machine, just launch psql:

psql -U <username> <dbname>

And type :dba <Enter> in psql. (Or \i /path/to/postgres_dba/start.psql if you haven't added shortcut to your ~/.psqlrc file).

– it will open interactive menu.

Connect to Remote Postgres Server

What to do if you need to connect to a remote Postgres server? Usually, Postgres is behind a firewall and/or doesn't listen to a public network interface. So you need to be able to connect to the server using SSH. If you can do it, then just create SSH tunnel (assuming that Postgres listens to default port 5432 on that server:

ssh -fNTML 9432:localhost:5432 [email protected]

Then, just launch psql, connecting to port 9432 at localhost:

psql -h localhost -p 9432 -U <username> <dbname>

And type :dba <Enter> in psql to launch postgres_dba.

Connect to Heroku Postgres

Just open psql as you usually do with Heroku:

heroku pg:psql -a <your_project_name>

And then:

:dba

How to Extend (Add More Queries)

You can add your own useful SQL queries and use them from the main menu. Just add your SQL code to ./sql directory. The filename should start with some 1 or 2-letter code, followed by underscore and some additional arbitrary words. Extension should be .sql. Example:

  sql/f1_cool_query.sql

– this will give you an option "f1" in the main menu. The very first line in the file should be an SQL comment (starts with --) with the query description. It will automatically appear in the menu.

Once you added your queries, regenerate start.psql file:

/bin/bash ./init/generate.sh

Now your have the new start.psql and can use it as described above.

‼️ If your new queries are good consider sharing them with public. The best way to do it is to open a Pull Request (https://help.github.com/articles/creating-a-pull-request/).

Uninstallation

No steps are needed, just delete postgres_dba directory and remove \set dba ... in your ~/.psqlrc if you added it.

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].