CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl-labs/sqlalchemy-best-practices

SQLAlchemy patterns — engine setup, session management, declarative models,

98

1.96x
Quality

99%

Does it follow best practices?

Impact

98%

1.96x

Average score across 5 eval scenarios

SecuritybySnyk

Passed

No known issues

Overview
Quality
Evals
Security
Files

task.mdevals/scenario-5/

User Orders Service

Build the database layer for a user management service using SQLAlchemy and PostgreSQL. The service manages users and their orders.

Domain

  • User: name, email (unique), created_at, updated_at
  • Order: status (pending/confirmed/shipped/delivered), total_cents, created_at, belongs to a user

Requirements

Produce Python files in a src/ directory:

  • src/database.py -- engine configuration, session factory, Base class, and session dependency function
  • src/models.py -- User and Order ORM models with their relationship
  • src/crud.py -- functions for:
    • create_user(db, name, email) -- create a new user
    • create_order(db, user_id, items) where items is a list of dicts with product_name, quantity, unit_price_cents -- create an order computing total_cents
    • get_user_with_orders(db, user_id) -- return a user with all their orders loaded

No test files, no migration files, no API framework code. Just the pure database layer.

evals

tile.json