"""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", "Book"]
@dataclass(frozen=True)
class Book:
id: int
title: str
author: str
SCHEMA = Schema(
tables=(
Table(name='books', columns=('id', 'title', 'author'), primary_key='id'),
),
operations=(
Operation(
identifier='FEATURE-BOOK-001',
table='books',
verb='create',
inputs=('title', 'author'),
row=Book,
columns=('id', 'title', 'author'),
),
Operation(
identifier='FEATURE-BOOK-002',
table='books',
verb='get',
inputs=('id',),
row=Book,
columns=('id', 'title', 'author'),
),
Operation(
identifier='FEATURE-BOOK-003',
table='books',
verb='list',
inputs=(),
row=Book,
columns=('id', 'title', 'author'),
),
Operation(
identifier='FEATURE-BOOK-004',
table='books',
verb='delete',
inputs=('id',),
row=None,
columns=(),
),
),
)
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