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-3/

Local Inventory Tracker

Problem/Feature Description

A small retail shop needs a local inventory tracking system built with Python and FastAPI. Use SQLite for the database (single machine, no cloud database needed).

The system needs:

  • Products: name, SKU (unique), category, unit cost in dollars, sell price in dollars, current stock quantity, reorder threshold.
  • Stock movements: record every stock change (received shipment, sold, returned, adjusted). Each movement has a product reference, quantity change (positive for inbound, negative for outbound), movement type, a note, and timestamp.
  • Receive shipment endpoint: accept a list of items (product SKU + quantity) from a supplier delivery. Update stock quantities for all items. This must be atomic -- if any SKU is invalid, none of the stock updates should apply.
  • Record a sale endpoint: decrease stock for a list of items sold. Must check that sufficient stock exists for each item before committing. If any item has insufficient stock, reject the entire sale.
  • Stock report endpoint: current stock levels for all products, with a flag for items below reorder threshold.
  • Movement history endpoint: list all stock movements for a product within a date range.

Output Specification

Produce:

  • app/db.py -- Database connection and initialization
  • app/models.py -- Pydantic models for request/response
  • app/routes.py -- FastAPI route handlers
  • app/main.py -- FastAPI application entry point
  • requirements.txt -- With dependencies

Complete Python code, no placeholders or TODO comments.

evals

tile.json