Sync Product Catalog from CSV to SQLite Database
Beginner Mode

Start your terminal to use beginner mode.

Scenario

A product catalog needs to be synchronized with updates from a CSV file. New products must be inserted and existing products with price changes must be updated in the database.

Task

Write a Python script at /home/interview/sync_catalog.py that reads /home/interview/catalog_updates.csv, compares it against the SQLite database at /home/interview/products.db, inserts new products, and updates prices for existing products that have changed. Use a transaction to ensure all changes are applied atomically.

Note: The database has a table named products with columns: id (INTEGER PRIMARY KEY), name (TEXT), price (REAL).

Example

# Database before sync
id=1, name="Product A", price=10.99

# CSV contains
1,Product A,12.99  (price changed)
2,Product B,15.99  (new product)

# Database after sync
id=1, name="Product A", price=12.99  (updated)
id=2, name="Product B", price=15.99  (inserted)

Terminal requires a larger screen

Open this page on a desktop or tablet (≥ 768px) to launch the terminal and practice hands-on.

Linux Terminal Environment

Write and execute your solution in the terminal below.

Sign In

Track

Question Difficulty Company Access
Need more practice in this area? Explore more questions →