Tools to gather useful information from PostgreSQL
Project description
https://github.com/idlesign/pg_analyse
Description
Tools to gather useful information from PostgreSQL
This package can function both as Python module and as a command line utility. Command line interface can show gathered information in the form of tables or JSON.
Use it to gather information manually or in Continuous Integration.
Can give you some information on:
Index health (bloat, duplicates, unused, etc.);
Tables missing PKs and indexes.
Requirements
Python 3.6+
Installation
; If you want to use it just as Python module:
$ pip install pg_analyse
; If you want to use it from command line:
$ pip install pg_analyse[cli]
Usage
Hint
One can set PG_ANALYSE_DSN environment variable instead of explicitly passing DSN to connect to PostgreSQL. If envbox is installed this variable can be defined in .env file .
Python module
from pg_analyse.toolbox import Analyser
analyser = Analyser(dsn='user=test')
inspections = analyser.run()
inspection = inspections[0]
print(inspection.alias)
print(inspection.result)
CLI
; Show known inspections and descriptions:
$ pg_analyse inspections
; Use DSN from the environment variable (see hint above),
; print out human values (e.g. sizes) in human-friendly way:
$ pg_analyse run --human
; Run certain inspections:
$ pg_analyse run --one idx_unused --one idx_nulls
; Use explicitly passed DSN:
$ pg_analyse run --dsn "host=myhost.net port=6432 user=test password=xxx sslmode=verify-full sslrootcert=/home/my.pem"
; Output analysis result as json (instead of tables):
$ pg_analyse run --fmt json
Adding Inspection
To add a new inspection to pg_analyse:
Compose SQL for inspection and put it into a file under sql/ directory.
Add a subclass of Inspection into inspections/bundled.py. Fill in alias, sql_name attributes (see docstrings in Inspection).
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for pg_analyse-0.1.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5d3ba4fcb4e9718c3117af62d14ba55a713e3241a0a7897e15c08ca98d8137d2 |
|
MD5 | a90003fdb18ba6d90eac4730d1ed7908 |
|
BLAKE2b-256 | bb93481e5d7fea8e80772dbfb96e16299ff2f2c9e454d2143658edeefc705011 |