Project 3: CLI-based To-do App
Project 3: CLI-Based To-Do App in Python
In this project, we apply our cumulative understanding of Object-Oriented Architecture, SQLite Database Management, Datetime Arithmetic, and Defensive Error Handling to engineer a high-productivity Command-Line Task & To-Do Management Engine.
1. System Architecture & Capabilities
Our To-Do application manages task lifecycles stored in an embedded tasks.db SQLite database:
+-----------------------------------------------------------------------------+ | tasks.db | | | | id (PK) | title | priority (HIGH/MED/LOW) | status | due_date | created_at | +-----------------------------------------------------------------------------+
Key Capabilities:
- 1Full CRUD Lifecycle: Add, list, search, update status, and delete tasks.
- 2Priority Hierarchy: Prioritizes tasks by
HIGH,MEDIUM, andLOW. - 3Deadline Awareness: Compares task deadlines against current system time via the
datetimemodule to flag OVERDUE tasks with visual alert tags. - 4Resilient CLI: Parameterized SQL queries safeguard against SQL injection, while comprehensive error trapping handles invalid date formats.
2. Complete Project Implementation
Visual Architecture & Process Flow
How data and code flow step-by-step
3. Sample Execution Simulation
Multiple Choice Questions
1. How does the SQLite table schema prevent arbitrary invalid values from being stored in the status column?
A. With an external Python cron job B. Using a SQL CHECK(status IN ('PENDING', 'IN_PROGRESS', 'COMPLETED')) constraint C. By making the column a Primary Key D. Status cannot be constrained in SQLite Answer: B Explanation: The SQL CHECK constraint validates that inserted or updated strings match one of the enumerated allowable states.
2. How does the application detect that a task is OVERDUE?
A. By pinging an external atomic clock API B. By comparing the task's due_date string against date.today().strftime("%Y-%m-%d") for incomplete tasks C. By catching a TimeoutError D. Tasks cannot be overdue in SQLite Answer: B Explanation: ISO formatted dates (YYYY-MM-DD) are lexicographically sortable; comparing due_date < today_str identifies dates in the past.
3. Which SQL clause allows custom hierarchical sorting (e.g. HIGH before MEDIUM before LOW)?
A. ORDER BY priority DESC B. ORDER BY CASE priority WHEN 'HIGH' THEN 1 WHEN 'MEDIUM' THEN 2 WHEN 'LOW' THEN 3 END C. GROUP BY priority D. PARTITION BY priority Answer: B Explanation: A SQL CASE statement inside an ORDER BY clause assigns custom integer weights to categorical strings for custom sorting.
4. What does cursor.lastrowid return after executing INSERT INTO tasks ...?
A. The number of rows in the table B. The newly generated auto-incrementing integer ID of the created task C. A list of all task names D. None Answer: B Explanation: cursor.lastrowid stores the generated primary key rowid of the most recently inserted record.
5. Why is parameterized SQL syntax (VALUES (?, ?, ?)) used when adding new tasks?
A. To prevent SQL Injection attacks from malicious task title strings B. To compress task titles in memory C. Parameterized queries run only on Saturdays D. It is mandatory for Python functions Answer: A Explanation: Parameterized placeholders treat values strictly as literal data rather than executable SQL code, preventing SQL injection vulnerabilities.
Library Management System
Continue learning with hands-on practice, examples, and exercises in the upcoming topic.
Related Lessons
| Previous Lesson | Next Lesson |
|---|---|
| Project 2: API-based Dictionary App | Library Management System |
Practice Quiz
Test your understanding of this lesson with 5 questions. Each question has one correct answer.