CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl-labs/sqlite-python-best-practices

SQLite best practices for Python -- PRAGMAs per connection, context manager transactions, parameterized queries, row_factory, executemany, FK indexes

92

1.73x
Quality

90%

Does it follow best practices?

Impact

97%

1.73x

Average score across 5 eval scenarios

SecuritybySnyk

Passed

No known issues

Overview
Quality
Evals
Security
Files

task.mdevals/scenario-1/

Book Lending Library

Problem/Feature Description

A small community library needs a book lending management system built with Python and FastAPI. Use SQLite for the database (runs on a single Raspberry Pi at the front desk).

The system needs:

  • Books: title, author, ISBN (unique), genre, total copies owned, available copies count.
  • Members: name, email (unique), membership date, status (active/suspended).
  • Loans: tracks which member borrowed which book, with checkout date, due date (14 days from checkout), return date (null until returned), and status (active/returned/overdue).
  • Check out a book: verify the member is active, the book has available copies, and the member does not already have 5 active loans. Decrease available copies and create the loan record together. If any check fails, nothing should change.
  • Return a book: mark the loan as returned with today's date and increase the book's available copies. Both must happen together.
  • Bulk add books: accept a list of books and add them all, or none if any ISBN is a duplicate.
  • Overdue report: list all loans past their due date that have not been returned, including member and book details.
  • Member history: all loans for a member, sorted by checkout date descending.

Output Specification

Produce:

  • app/db.py -- Database connection and schema initialization
  • app/schemas.py -- Pydantic models
  • app/books.py -- Book-related endpoints
  • app/loans.py -- Loan-related endpoints
  • app/main.py -- FastAPI application
  • requirements.txt -- With dependencies

Complete Python code, no placeholders or TODO comments.

evals

scenario-1

criteria.json

task.md

tile.json