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

Bulk Product Import Service

Build a data import service using SQLAlchemy that bulk-imports product records from CSV data into PostgreSQL.

Domain

  • Category: name (unique)
  • Product: name, sku (unique), price_cents, belongs to a category

Requirements

Produce Python files in a src/ directory:

  • src/database.py -- engine configuration, session factory, Base class, and session dependency
  • src/models.py -- Category and Product ORM models
  • src/importer.py -- an import_products(db, rows) function that takes a list of dicts, each with keys name, sku, price_cents, and category_name. For each row:
    • Find or create the category by name
    • Insert the product into that category
    • The function may receive thousands of rows, so it should be efficient
    • If a product with the same SKU already exists, skip it and continue with the next row

No test files, no migration files, no API framework code.

evals

tile.json