CS File
CS File
PROJECT FILE
To-Do List Using python and MySQL
Delhi Public School, Indira Nagar, Lucknow, has satisfactorily completed the PROJECT
First and foremost, I would like to extend my heartfelt gratitude to our respected Principal,
Mrs. Ghazal Afsar Ruby, for her constant encouragement and support. Her leadership has fostered an
environment of learning and innovation, which has been instrumental in my growth and development throughout
this project.
I would also like to thank my project advisor, Mrs. Pinkie Srivastava, for her invaluable guidance, patience, and
support during the course of this project. Her expertise and insightful feedback played a crucial role in shaping the
direction and quality of the work presented here, especially in enhancing my understanding of Python
programming and database management with MySQL.
I am deeply grateful to Delhi Public School, Indira Nagar for providing the resources and facilities necessary for
the successful completion of this project. The access to software, hardware, and academic materials was vital in
bringing this project to fruition.
Furthermore, I would like to acknowledge the contributions of my classmates and peers, whose discussions and
collaborative spirit enriched my learning experience. Their willingness to share knowledge and exchange ideas
was invaluable during the development phases of this project.
My deepest appreciation also goes to my family, whose unwavering support and understanding have been my
constant source of strength. They have always been there to encourage me during challenging moments, and their
belief in my abilities has been a motivating force throughout this journey.
Finally, I want to extend my gratitude to the numerous online tutorials, blogs, and educational platforms that
provided guidance and inspiration during this project. Their wealth of information greatly facilitated my learning
process.
Thank you.
This project is a Simple To-Do List Application built in Python, leveraging MySQL for database management. It
allows users to manage their daily tasks efficiently, offering a structured and interactive way to create, update, and
track tasks. The application is designed to run in a command-line interface and provides essential task management
features such as adding tasks, modifying them, marking tasks as complete, archiving completed tasks, and viewing
both active and archived tasks.
Key Features:
1. Add Tasks: Users can create new tasks with details like priority (High, Medium, Low), due dates, categories
(e.g., Work, Personal), recurrence (e.g., daily, weekly), and additional notes.
2. View Tasks: The user can view all active tasks in a neatly formatted list that displays task details such as
priority, due date, and whether the task is completed or not.
3. Modify Tasks: The application allows users to update existing tasks by changing the description, priority, due
date, category, and other attributes.
4. Mark as Complete: Once a task is completed, it can be marked as such, allowing users to distinguish
between pending and completed tasks.
5. Archive Completed Tasks: Users can archive tasks that have been marked as completed, which removes
them from the active task list but keeps them stored in the system for future reference.
6. View Archived Tasks: Archived tasks can be viewed separately, allowing users to track the tasks they’ve
already completed.
7. Delete Tasks: If a task is no longer relevant, users can delete it permanently from the system.
Technologies Used:
• Python: The main programming language used for the logic and control flow of the application.
• MySQL: The database management system used to store and retrieve tasks.
• MySQL Connector for Python: A library that facilitates the connection and communication between the
Python program and the MySQL database.
Benefits:
• Task Organization: The application helps users manage their daily activities and stay organized by tracking
tasks with additional details such as priority and due dates.
• Simple and User-Friendly: The interface is minimal and easy to use, with simple text-based prompts guiding
the user through various options.
• Persistence: Tasks are stored in a MySQL database, ensuring that data remains intact between sessions.
• Flexibility: Users can create, update, and remove tasks easily, as well as review their completed tasks
through the archiving feature.
This project demonstrates the integration of Python and MySQL to build a functional to-do list system. It is a perfect
starting point for users who want to learn about database management in Python and develop practical applications for
task management.
Coding:
import mysql.connector
from datetime import datetime
def add_task():
task = input("Enter task: ")
priority = input("Enter priority (High, Medium, Low): ")
due_date = input("Enter due date (YYYY-MM-DD) or leave blank: ") or None
category = input("Enter category (e.g., Work, Personal): ")
recurrence = input("Enter recurrence (daily, weekly, monthly) or leave blank: ") or None
notes = input("Enter additional notes or leave blank: ") or None
def delete_task():
query = "SELECT * FROM tasks WHERE archived = FALSE"
cursor.execute(query)
tasks = cursor.fetchall()
if not tasks:
print("No tasks available.")
else:
for task in tasks:
print(f"{task[0]} - {task[1]}")
task_id = int(input("Enter task number to delete: "))
query = "DELETE FROM tasks WHERE id = %s"
cursor.execute(query, (task_id,))
cnx.commit()
print("Task deleted successfully!")
def modify_task():
query = "SELECT * FROM tasks WHERE archived = FALSE"
cursor.execute(query)
tasks = cursor.fetchall()
if not tasks:
print("No tasks available.")
else:
for task in tasks:
print(f"{task[0]} - {task[1]}")
task_id = int(input("Enter task number to modify: "))
new_task = input("Enter the new task description: ")
new_priority = input("Enter the new priority (High, Medium, Low): ")
new_due_date = input("Enter the new due date (YYYY-MM-DD) or leave blank: ") or None
new_category = input("Enter the new category or leave blank: ") or None
new_recurrence = input("Enter the new recurrence (daily, weekly, monthly) or leave blank: ") or None
new_notes = input("Enter additional notes or leave blank: ") or None
query = """
UPDATE tasks
SET task = %s, priority = %s, due_date = %s, category = %s, recurrence = %s, notes = %s
WHERE id = %s
"""
cursor.execute(query,(new_task,new_priority,new_due_date,new_category,new_recurrence,new_notes,
task_id))
cnx.commit()
print("Task modified successfully!")
def complete_task():
query = "SELECT * FROM tasks WHERE archived = FALSE"
cursor.execute(query)
tasks = cursor.fetchall()
if not tasks:
print("No tasks available.")
else:
for task in tasks:
print(f"{task[0]} - {task[1]}")
task_id = int(input("Enter task number to mark as completed: "))
query = "UPDATE tasks SET completed = TRUE WHERE id = %s"
cursor.execute(query, (task_id,))
cnx.commit()
print("Task marked as completed.")
def archive_completed_tasks():
query = "UPDATE tasks SET archived = TRUE WHERE completed = TRUE"
cursor.execute(query)
cnx.commit()
print("Completed tasks archived.")
def view_archived_tasks():
query = "SELECT * FROM tasks WHERE archived = TRUE"
cursor.execute(query)
tasks = cursor.fetchall()
if not tasks:
print("No archived tasks available.")
else:
for task in tasks:
print(f"{task[0]} - {task[1]} - Archived")
def main():
while True:
print("\n--- To-Do List ---")
print("1. Add Task")
print("2. View Tasks")
print("3. Delete Task")
print("4. Modify Task")
print("5. Complete Task")
print("6. Archive Completed Tasks")
print("7. View Archived Tasks")
print("8. Exit")
choice = input("Choose an option: ")
if choice == "1":
add_task()
elif choice == "2":
view_tasks()
elif choice == "3":
delete_task()
elif choice == "4":
modify_task()
elif choice == "5":
complete_task()
elif choice == "6":
archive_completed_tasks()
elif choice == "7":
view_archived_tasks()
elif choice == "8":
print("Goodbye!")
break
else:
print("Invalid choice. Please try again.")
if __name__ == "__main__":
main()
Commands:
1 - Finish project report - Priority: High - Due: 2024-10-01 - Category: Work - Completed: False
1 - Complete project report and submit - Priority: High - Due: 2024-09-30 - Category: Work - Completed:
True
1.Described Table: