ddd.infrastructure.db_service.postgres_db_service

API

class ddd.infrastructure.db_service.postgres_db_service.PostgresDbService(dsn, log_service, min_size=20, max_size=20)

Bases: ddd.infrastructure.db_service.db_service.DbService

A postgres db service.

Parameters
  • dsn – the dsn (connection string).

  • log_service – the log service.

  • min_size (int, optional) – minimum number of connections in the db pool.

  • max_size (int, optional) – maximum number of connections in the db pool.

async start()

Starts the db service.

async stop()

Stops the db service.

Examples

Create a postgres_db_service and start it:

from ddd.infrastructure.db_service.postgres_db_service import PostgresDbService


log_service = ...

db_service = \
    PostgresDbService(
        dsn="postgresql://localhost:5432",
        log_service=log_service,
        min_size=20,
        max_size=20,
    )

await db_service.start()