simple_postgres_setup is a python utility for deploying PostgreSQL databases from a yaml configuration file.
Project description
simple_postgres_setup
This package provides two main functions for managing a PostgreSQL database:
-
setup_database("path_to_config.yml")
Sets up a PostgreSQL database using:- Credentials from your
.envfile - Additional parameters specified in your
config.yml
- Credentials from your
-
drop_database("path_to_config.yml")
Drops (tears down) the same PostgreSQL database, reverting changes made during the setup.
scope
- define the database name
- define the database schemas and schema comments
2.1 per schema there will be three default functional roles:
- schema_name_all = all privileges regarding the schema are granted
- schema_name_use = usage on existing schema assets are granted
- schema_name_read = only select on tables is granted
- define the login roles (users)
- define the access policies for the users by connecting the login roles with the functional roles per schema (see example configuration in the template subfolder)
usage
- install with pip (see installation) or other package manager
- create directory
- create config.yml and .env in the directory (use template files provided in the 'template' subfolder of this pacakge)
- define output directory in your config.yml as a relative path from the directory you execute the functions from, e.g. THIS directory
- provide all required input in the .env and config.yml files
- run setup
Requirements
- Python 3.10+
- An existing PostgreSQL server/cluster with Postgreql > 13
- A
.envfile containing the following DB connection parameters (e.g., hostname, port, user credentials):
# database connection variables
HOST=some_host
PORT='some_port_number'
DB=postgres # this whole software only works with postgres
USER=postgres_or_other_superuser
PWD=some_password
- A
config.ymlspecifying how to configure the database and where to store output artifacts.
NOTE: An example configuration file is included in the templates subfolder of this package: templates/config.yml.example
Installation
-
Make sure you have
pipinstalled (or use Poetry / another compatible Python package manager). -
Install from PyPI (or from source) by running:
pip install simple_postgres_setup
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file simple_postgres_setup-0.2.1.tar.gz.
File metadata
- Download URL: simple_postgres_setup-0.2.1.tar.gz
- Upload date:
- Size: 13.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.1 CPython/3.10.18 Linux/6.11.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fda9fb7a6bd753376bf8f51e4b2eb0cc9090f3d23789255d111ae6a3a4c9f28b
|
|
| MD5 |
fb5298f8255b3615871de1bbfe10fd05
|
|
| BLAKE2b-256 |
fd34bf3005d5c8db32c2f35a1ef2f738e353b092aabb6ebd752587105c1d6836
|
File details
Details for the file simple_postgres_setup-0.2.1-py3-none-any.whl.
File metadata
- Download URL: simple_postgres_setup-0.2.1-py3-none-any.whl
- Upload date:
- Size: 22.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.1 CPython/3.10.18 Linux/6.11.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c357c929618a7338a767657fe2e5d1c59229f5a388e93043a61f2ffad6a380a8
|
|
| MD5 |
0dedf66f3c367100f5e5f49bda9731fd
|
|
| BLAKE2b-256 |
dafe941d310cf5706cef82a411e835b77dce0a028610b6e46bdbbb655076f1b5
|