runtime
396 / 500
question 396 Software Architecture · medium

Fix the adapter that leaks database rows

The pricing core works with product dictionaries (product["price"]). Its SQLite adapter returns raw database rows, which are tuples, so the core crashes with TypeError: tuple indices must be integers. Fix the adapter (the core must not learn about SQL rows): get returns a dictionary with sku, name and price, or None for an unknown SKU.

ClassSqliteProducts(connection) with get(sku)
Returns{"sku": ..., "name": ..., "price": ...} or None
Coreprice_with_tax(store, sku, rate) (given) must stay unchanged

Loading your progress…

Fix the adapter that leaks database rows — Python practice · Runtime