"""Generated by Drydock from DATABASE.md. Do not edit; edit the declaration and rebuild.
This module is the declared persistence contract as Python: the tables, the operations each
Blueprint cites, and the row a read or a create returns. It contains no SQL — statements are built by the
driver for the engine in use, so a parameter placeholder never appears here.
"""
from __future__ import annotations
from dataclasses import dataclass
from .db import Database, Operation, Schema, Table
__all__ = ["SCHEMA", "open_database", "BookRow", "DeletedBook"]
@dataclass(frozen=True)
class BookRow:
id: int
title: str
author: str
insertion_order: int
@dataclass(frozen=True)
class DeletedBook:
id: int
SCHEMA = Schema(
tables=(
Table(name='books', columns=('id', 'title', 'author', 'insertion_order'), primary_key='id'),
),
operations=(
Operation(
identifier='FEATURE-READING-LIST-001',
table='books',
verb='list',
inputs=(),
row=BookRow,
columns=('id', 'title', 'author', 'insertion_order'),
),
Operation(
identifier='FEATURE-ADD-BOOK-001',
table='books',
verb='create',
inputs=('title', 'author', 'insertion_order'),
row=BookRow,
columns=('id', 'title', 'author', 'insertion_order'),
),
Operation(
identifier='FEATURE-REMOVE-BOOK-001',
table='books',
verb='delete',
inputs=('id',),
row=DeletedBook,
columns=('id',),
),
),
)
def open_database(dsn: str) -> Database:
"""Open the declared store. The engine is selected from the DSN, not from the build."""
return Database(dsn, SCHEMA)
Run artifact