SQLAlchemy patterns — engine setup, session management, declarative models,
98
99%
Does it follow best practices?
Impact
98%
1.96xAverage score across 5 eval scenarios
Passed
No known issues
Build the database layer for an inventory management system using SQLAlchemy and PostgreSQL.
Produce Python files in a src/ directory:
src/database.py -- engine configuration, session factory, Base class, and session dependencysrc/models.py -- Category, Product, and StockMovement ORM models with relationshipssrc/crud.py -- functions for:
add_product(db, name, sku, price_cents, category_id) -- add a product, handle duplicate SKU gracefullyrecord_stock_movement(db, product_id, quantity_change, reason) -- record inventory changeget_product_detail(db, product_id) -- return product with its category and recent stock movementsNo test files, no migration files, no API framework code.