Menu

1 / 2

Stop Running psql Commands by Hand — Build a REST API for PostgreSQL User Management

DEV Community: postgres·Pranay Ravi·6 months ago
#yBVRPdSS
#dev#user#users#create#article
Reading 0:00
15s threshold

If you manage PostgreSQL databases across multiple environments, you've probably done this:

SSH to the DB host (or connect via psql )

Run CREATE USER jsmith CONNECTION LIMIT 20 PASSWORD '...'

Slack the password to the developer

Forget to log it anywhere

Repeat for every environment, every onboarding, every access request

It's tedious, error-prone, and leaves zero audit trail. Here's a better way.

What I Built

pg-user-api is a lightweight Flask REST API that wraps PostgreSQL user provisioning in clean HTTP endpoints. You register your databases once in a SQLite inventory, then any tooling — CI pipelines, internal portals, Ansible playbooks, or a plain curl — can create and manage users across environments without ever touching psql .

GitHub: pcraavi/PostgreSQL-user-creation-API

The Problem It Solves

In teams that span dev, QA, UAT, and prod, you end up with different patterns of users:

App service accounts — named after the host/port combo ( web01_8080 )

Kubernetes workload accounts — named after…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.