Export SQLite Database Query Results to CSV File
Beginner Mode

Start your terminal to use beginner mode.

Scenario

A SQLite database contains product data that needs to be exported for analysis. You need to query the database and save the results to a CSV file.

Task

Complete the Python script at /home/interview/export_products.py to execute a SELECT query on the products table in /home/interview/products.db, fetch all results, and export them to /home/interview/products_export.csv.

Database Schema

Table: products

  • id (INTEGER)
  • name (TEXT)
  • category (TEXT)
  • price (REAL)
  • stock (INTEGER)

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 →