Skip to main content

Postgraas is a super simple PostgreSQL-as-a-service

Project description

https://travis-ci.org/blue-yonder/postgraas_server.svg?branch=master https://coveralls.io/repos/github/blue-yonder/postgraas_server/badge.svg?branch=master

Postgraas is a super simple PostgreSQL-as-a-service

What is Postgraas?

Postgraas offers CRUD operations for complete PostgreSQL database instances via a simple REST api. The database instances are docker containers and the API server is a few hundred LoC Flask application. It is not meant as a production ready solution, but more as a proof-of-concept to spread the idea of creating “as-a-service” services easily yourself and should inspire you to start working on your own cloud infrastructure today. But in fact, it proofs the concept very well and it turned out to be super useful for delivering a PostgreSQL instance if you need one fast, e.g. for integration tests, for playing around with fancy ShowHN projects or other experiments. The CRUD management via REST api is of course also a necessary prerequisite for building an automated continuous delivery pipeline for a modern software project.

Installation

You can find detailed instructions in the docs

Install via pip:

pip install postgraas_server

Start the WSGI api server for example via gunicorn:

pip install gunicorn
gunicorn -w 4 -b 0.0.0.0:8080 postgraas_server.postgraas_api:app

Usage

We need to send all the required parameters for the creation as an http request. This is quite convenient by creating a file e.g. my_postgraas.json:

{
    "postgraas_instance_name": "my_postgraas",
    "db_name": "my_db",
    "db_username": "db_user",
    "db_pwd": "secret"
}

and making a POST request to the collection resource with curl:

curl -H "Content-Type: application/json" -X POST --data @my_postgraas.json http://localhost:8080/api/v2/postgraas_instances

now your instance is created and as a response you get the details of your instance:

{
     "postgraas_instance_id": 1,
     "container_id": "193f0d94d49fa26626fdbdb583e9453f923468b01eac59207b4852831a105c03",
     "db_pwd": "secret",
     "host": "not imlemented yet",
     "db_name": "my_db",
     "db_username": "db_user",
     "port": 54648
}

We are now able to connect to the database for example via psql:

psql -h localhost -p 54648 -U db_user my_db

Awesome, isn’t it?

Development

Run the tests

You need to have docker installed

Make sure you pull the right docker image:

docker pull postgres:9.4

Make a virtualenv and install the requirements including the dev requirements and a local editable install of the package, for convenience you can install the requirements.in

pip install -r requirements.in
pip install -r requirements_dev.txt
pip install -e .

For the tests you need a running postgres meta database and set some environment variables accordingly. There is a convenience script to set this all up using a docker postgres database:

. setup_integration_test_docker.sh

Now you should be able to execute the tests:

pytest tests/

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

postgraas_server-2.1.0.tar.gz (40.1 kB view details)

Uploaded Source

Built Distribution

postgraas_server-2.1.0-py2.py3-none-any.whl (20.5 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file postgraas_server-2.1.0.tar.gz.

File metadata

  • Download URL: postgraas_server-2.1.0.tar.gz
  • Upload date:
  • Size: 40.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.7.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/2.7.14

File hashes

Hashes for postgraas_server-2.1.0.tar.gz
Algorithm Hash digest
SHA256 207e237bbc862aff4e81448270be84cb51938c3b06b783856243f2080996541b
MD5 a86d274d7a2f3c6fa1613e8f1719a7b3
BLAKE2b-256 33346cdfba29ab1b159f29305c36e5d4c3685f1ab72b40c6a06dc5ffa31a574a

See more details on using hashes here.

File details

Details for the file postgraas_server-2.1.0-py2.py3-none-any.whl.

File metadata

  • Download URL: postgraas_server-2.1.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 20.5 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.7.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/2.7.14

File hashes

Hashes for postgraas_server-2.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 a8b7f859b2133032461ed96f276b6a9f50634d2c542219e0c89e462a98988f90
MD5 a8f7c8db6d6f2034045e9e29976b2506
BLAKE2b-256 532997af749b24ff80aac04bcc0fb4308bf9f7dbc91b01fcba445bff01c217e1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page