luplo.core.db

Database connection management.

Provides a thin wrapper around psycopg_pool.AsyncConnectionPool so the rest of the codebase doesn’t import pool internals directly.

Attributes

Functions

create_pool(→ Pool)

Create and open an async connection pool.

close_pool(→ None)

Gracefully close a connection pool.

Module Contents

luplo.core.db.DEFAULT_DB_URL = 'postgresql://localhost/luplo'
luplo.core.db.Pool
async luplo.core.db.create_pool(db_url: str | None = None, *, min_size: int = 1, max_size: int = 5) Pool

Create and open an async connection pool.

Parameters:
  • db_url – PostgreSQL connection string. Falls back to LUPLO_DB_URL env var, then postgresql://localhost/luplo.

  • min_size – Minimum connections kept open.

  • max_size – Maximum concurrent connections.

Returns:

An open AsyncConnectionPool ready for use.

async luplo.core.db.close_pool(pool: Pool) None

Gracefully close a connection pool.