Ctrl + k

or run

tessl search
Log in

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/sqlmodel@0.0.x
tile.json

tessl/pypi-sqlmodel

tessl install tessl/pypi-sqlmodel@0.0.0

SQLModel, SQL databases in Python, designed for simplicity, compatibility, and robustness.

Agent Success

Agent success rate when using this tile

85%

Improvement

Agent success rate improvement when using this tile compared to baseline

1x

Baseline

Agent success rate without this tile

85%

task.mdevals/scenario-4/

Product API Service

Build a REST API service for managing products in an e-commerce system. The service should provide endpoints for creating, reading, updating, and listing products with proper validation.

Requirements

Data Model

Products have the following attributes:

  • A unique identifier (auto-generated)
  • Name (required string)
  • Description (required string)
  • Price (required decimal number with 2 decimal places)
  • Stock quantity (required integer, must be >= 0)
  • Category (required string)

API Endpoints

Implement the following REST endpoints:

  1. POST /products/ - Create a new product

    • Accept product data in request body (without ID)
    • Validate all required fields
    • Store in database
    • Return created product with generated ID
  2. GET /products/{product_id} - Get a single product by ID

    • Return 404 if product not found
    • Return product data with all fields
  3. GET /products/ - List all products

    • Return list of all products
    • Each product should include all fields
  4. PATCH /products/{product_id} - Update an existing product

    • Accept partial product data (any fields can be updated)
    • Only update provided fields
    • Return updated product data
    • Return 404 if product not found

Data Validation

  • Price must be a positive decimal with exactly 2 decimal places
  • Stock quantity must be a non-negative integer
  • Name, description, and category cannot be empty strings

Implementation

@generates

Use an in-memory SQLite database for storage.

API

# FastAPI application with product management endpoints

Test Cases

  • Creating a product with valid data returns 200 status and includes generated ID @test
  • Getting a product by valid ID returns the correct product data @test
  • Getting a non-existent product returns 404 status @test
  • Listing products returns all created products @test
  • Updating a product with partial data only modifies provided fields @test

Dependencies { .dependencies }

sqlmodel { .dependency }

Provides database ORM with data validation support.

fastapi { .dependency }

Web framework for building APIs.

uvicorn { .dependency }

ASGI server for running FastAPI applications.