PostgreSQL database schema design and maintenance tools
Project description
# PostgreSQL Database Tools
Design, Create, Maintain and Document a Postgresql database using a yaml based
description file.
## Installation:
Download and install the tool.
```
git clone https://github.com/hendrikx-itc/pg-db-tools
sudo pip3 install pg-db-tools
```
## Usage
```
db-schema <command> [options]
commands:
compile compile output from schema definition
extract extract schema definition from source
doc documentation generation command
--help,-h display help information
```
### compile
```
db-schema compile <output-type> <schema-filename>
output-types:
dot Generate Graphviz DOT
sql Generate SQL
md Generate Markdown documentation
rst Generate reStructuresText documentation
```
### extract
```
db-schema extract <source>
sources:
from-db Extract from postgres database
```
```
db-schema extract from-db --format {yaml.json} [--owner OWNER] [schemas]
```
schemas:
* Multiple schemas can be supplied
* If no schema is supplied, all schemas are returned
Example:
```
PGHOST=localhost \
PGPORT=5432 \
PGUSER=postgres \
PGDATABASE=postgres \
db-schema extract from-db --format yaml
```
### doc
## Examples
Create sql from the example webshop.yaml
```
db-schema compile sql example/webshop.yaml
```
Create rst documentation from the example webshop.yaml
```
db-schema compile rst example/webshop.yaml
```
result:
```
Schema ``shop``
===============
Tables
------
Order
^^^^^
Contains all orders
+---------+--------------------------+----------+-------------+
| Column | Type | Nullable | Description |
+=========+==========================+==========+=============+
| id | integer | ✔ | Primary key |
+---------+--------------------------+----------+-------------+
| created | timestamp with time zone | ✔ | |
+---------+--------------------------+----------+-------------+
OrderLine
^^^^^^^^^
Contains all order lines for all orders
+------------+---------+----------+-------------+
| Column | Type | Nullable | Description |
+============+=========+==========+=============+
| id | integer | ✔ | Primary key |
+------------+---------+----------+-------------+
| order_id | integer | ✔ | |
+------------+---------+----------+-------------+
| line_nr | integer | ✔ | |
+------------+---------+----------+-------------+
| product_id | integer | ✔ | |
+------------+---------+----------+-------------+
| amount | integer | ✔ | |
+------------+---------+----------+-------------+
Schema ``public``
=================
```
## Description Format
One of the main components of the toolset is a database schema description
format. The description format is based on YAML, because it is easy to read and
write for humans.
See an example [here](https://github.com/hendrikx-itc/pg-db-tools/blob/master/example/webshop.yaml)
See the schema file [here](https://github.com/hendrikx-itc/pg-db-tools/blob/master/src/pg_db_tools/spec.schema)
## Note
This tool is specifically not meant as a cross database toolset, because
that usually causes compatibility headaches and multiple partially supported
database engines.
Design, Create, Maintain and Document a Postgresql database using a yaml based
description file.
## Installation:
Download and install the tool.
```
git clone https://github.com/hendrikx-itc/pg-db-tools
sudo pip3 install pg-db-tools
```
## Usage
```
db-schema <command> [options]
commands:
compile compile output from schema definition
extract extract schema definition from source
doc documentation generation command
--help,-h display help information
```
### compile
```
db-schema compile <output-type> <schema-filename>
output-types:
dot Generate Graphviz DOT
sql Generate SQL
md Generate Markdown documentation
rst Generate reStructuresText documentation
```
### extract
```
db-schema extract <source>
sources:
from-db Extract from postgres database
```
```
db-schema extract from-db --format {yaml.json} [--owner OWNER] [schemas]
```
schemas:
* Multiple schemas can be supplied
* If no schema is supplied, all schemas are returned
Example:
```
PGHOST=localhost \
PGPORT=5432 \
PGUSER=postgres \
PGDATABASE=postgres \
db-schema extract from-db --format yaml
```
### doc
## Examples
Create sql from the example webshop.yaml
```
db-schema compile sql example/webshop.yaml
```
Create rst documentation from the example webshop.yaml
```
db-schema compile rst example/webshop.yaml
```
result:
```
Schema ``shop``
===============
Tables
------
Order
^^^^^
Contains all orders
+---------+--------------------------+----------+-------------+
| Column | Type | Nullable | Description |
+=========+==========================+==========+=============+
| id | integer | ✔ | Primary key |
+---------+--------------------------+----------+-------------+
| created | timestamp with time zone | ✔ | |
+---------+--------------------------+----------+-------------+
OrderLine
^^^^^^^^^
Contains all order lines for all orders
+------------+---------+----------+-------------+
| Column | Type | Nullable | Description |
+============+=========+==========+=============+
| id | integer | ✔ | Primary key |
+------------+---------+----------+-------------+
| order_id | integer | ✔ | |
+------------+---------+----------+-------------+
| line_nr | integer | ✔ | |
+------------+---------+----------+-------------+
| product_id | integer | ✔ | |
+------------+---------+----------+-------------+
| amount | integer | ✔ | |
+------------+---------+----------+-------------+
Schema ``public``
=================
```
## Description Format
One of the main components of the toolset is a database schema description
format. The description format is based on YAML, because it is easy to read and
write for humans.
See an example [here](https://github.com/hendrikx-itc/pg-db-tools/blob/master/example/webshop.yaml)
See the schema file [here](https://github.com/hendrikx-itc/pg-db-tools/blob/master/src/pg_db_tools/spec.schema)
## Note
This tool is specifically not meant as a cross database toolset, because
that usually causes compatibility headaches and multiple partially supported
database engines.
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
pg-db-tools-1.0.2.tar.gz
(30.8 kB
view hashes)
Built Distributions
Close
Hashes for pg_db_tools-1.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2c76223b3d23979c88f877c69518c0eeb672bc6be13aa3d18f8db9c166db8313 |
|
MD5 | 35b190b5acfaa5466f83c85eca1416ff |
|
BLAKE2b-256 | 59109f9fb7a09ddc65d01610a4cf64c51055b7276dcdfc4a4b55d8c3a6b66084 |
Close
Hashes for pg_db_tools-1.0.2-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ba17d4c118a7a4ab534b02a29af6bafa036ce13d557d834aa1e25b13a54637f3 |
|
MD5 | 82ee418a10df7e543be2a37d9e0f4e6e |
|
BLAKE2b-256 | 78fe101f2df3670c4e6758d8836b55778fe8b0055e3274992599f7e107b5a6e1 |