standalone-service

Configure a standalone PostgreSQL module with its own connection pool and migrations.

Updated Jul 28, 2025
One-click install
npx skills add https://github.com/juanre/pgdbm --skill standalone-service
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: standalone-service
Source: https://github.com/juanre/pgdbm/tree/main/skills/standalone-service
Command: npx skills add https://github.com/juanre/pgdbm --skill standalone-service

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Solves the challenge of building modules that own their own PostgreSQL database by providing a complete standalone pattern with its own connection pool and migrations.

Core Features & Use Cases

  • Owns its database and pool; runs migrations in isolation.
  • Simple pattern for services that require full isolation or background workers.
  • End-to-end lifecycle: configure, connect, migrate, use, and disconnect.

Quick Start

  • Install pgdbm in your environment (pip install pgdbm).
  • Create a DatabaseConfig with your dedicated PostgreSQL connection string.
  • Initialize AsyncDatabaseManager with the config and call connect().
  • Create AsyncMigrationManager with a migrations_path and a unique module_name, then call apply_pending_migrations().
  • Use the manager to run queries, then call disconnect() on shutdown.

Frequently Asked Questions about standalone-service

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I set up a PostgreSQL database for a standalone Python service?

Set up a standalone PostgreSQL database by installing pgdbm, creating a DatabaseConfig with your connection string, initializing AsyncDatabaseManager, and calling connect(). This gives your service its own isolated connection pool without relying on shared infrastructure.

Can I run database migrations automatically when my Python service starts?

Yes. Create an AsyncMigrationManager with your migrations_path and a unique module_name, then call apply_pending_migrations() during initialization. Migrations run in isolation for your service's database before queries execute.

What's the best way to manage database connections for background workers in Python?

Use the standalone pattern with AsyncDatabaseManager to give each background worker its own connection pool and migrations. This approach isolates workers, prevents connection conflicts, and ensures clean lifecycle management with connect() and disconnect().

Do I need a shared database pool for development and testing environments?

No. The standalone pattern eliminates shared pools by providing each service, worker, or test environment with its own AsyncDatabaseManager instance, pool, and migrations—simplifying isolation and teardown.

How do I handle database teardown and disconnection in a standalone service?

Call disconnect() on your AsyncDatabaseManager during shutdown. This cleanly closes the connection pool for your service's dedicated PostgreSQL database and ensures proper resource cleanup.

What PostgreSQL features does the standalone pattern support?

The standalone pattern uses standard pgdbm primitives—DatabaseConfig, AsyncDatabaseManager, and AsyncMigrationManager—supporting async queries, connection pooling, and migration execution for any PostgreSQL database owned by your service.