A simple, robust, and interactive Command-Line Interface (CLI) application for managing your daily tasks. This project uses Python and MongoDB to provide a persistent storage solution for your to-do items.
-
Features
-
Tech Stack
-
Prerequisites
-
Installation
-
Usage
-
Screenshots
-
Code Overview
-
Create: Add new tasks to your to-do list.
-
View: Display all your current tasks in a clean, numbered list.
-
Update: Modify an existing task by its number.
-
Delete: Remove a single task or wipe all tasks at once.
-
Persistent Storage: Your tasks are saved in a MongoDB database, so you'll never lose them.
-
User-Friendly Interface: Clear instructions and input validation for a smooth experience.
-
Backend: Python
-
Database: MongoDB
-
Driver: PyMongo
Before you begin, ensure you have the following installed on your system:
-
Python 3.x: Make sure Python is installed and configured in your system's PATH.
-
MongoDB: A running instance of MongoDB is required. You can install it locally or use a cloud service like MongoDB Atlas.
-
PyMongo Driver: The official Python driver for MongoDB.
- Clone the repository:
git clone https://github.com/your-username/your-repo-name.git
cd your-repo-name
- Install the PyMongo library:
pip install pymongo
- Configure the MongoDB connection:
Open the script and ensure the uri variable points to your MongoDB instance. The default is set for a local instance. Python
uri = "mongodb://localhost:27017/"
To run the application, simply execute the Python script from your terminal:
python your_script_name.py
Key Functions
-
fetch_tasks(): Retrieves all tasks from the MongoDB collection and stores them in a local list.
-
add_task(description): Creates a new task document and inserts it into the database.
-
view_tasks(): Prints the list of all current tasks to the console.
-
update_task(task_number, new_task): Finds a task by its list number and updates its description in the database.
-
delete_task(task_number): Deletes a specific task from the database.
-
delete_all_tasks(): Removes all documents from the tasks collection.
Main Loop
The application runs in a while True loop, clearing the screen and displaying the updated task list after each action. It uses a match statement to handle user choices for creating, updating, or deleting tasks. Input validation is included to ensure the program runs smoothly.