0% found this document useful (0 votes)
32 views

CS File

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views

CS File

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

Delhi Public School

Indira Nagar, Lucknow

PROJECT FILE
To-Do List Using python and MySQL

Project in Computer Science (083)


Subject Teacher: Ms. Pinkie Srivastava

Name: Arish Mukarram Khan


Class: XII
Section: B
Session: 2024-2025
Group Members: Arish Mukarram Khan , Hamza Mumtaz and Murtaza Siddiqui
CERTIFICATE

This is to certify that Master Arish Mukarram Khan

Roll no ________________________________________ class XII B studying in

Delhi Public School, Indira Nagar, Lucknow, has satisfactorily completed the PROJECT

titled To-Do List using Python and MySQL

as a part of course completion in pursuance of AISSCE (Class XII) practical examination

in subject Computer Science (083)

as per the guidelines issued by the CBSE.

The project has been executed by him/her under the guidance of

Ms. Pinkie Srivastava

Signature of the Signature of the Signature of the


Internal Examiner External Examiner Principal
Acknowledgement:

I am immensely grateful for the opportunity to present this project on creating a


To-Do List application using Python and MySQL. This project has been a significant learning experience, and
I would like to express my sincere appreciation to everyone who contributed to its successful completion.

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.

Arish Mukarram Khan


About Project

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

# MySQL database connection settings


config = {
'user': ‘node41',
'password': “root”,
'host': “root”,
'database': “todolist”,
}

# Establish a connection to the database


cnx = mysql.connector.connect(config)

# Create a cursor object to execute SQL queries


cursor = cnx.cursor()

# Create the tasks table if it doesn't exist


cursor.execute("""
CREATE TABLE IF NOT EXISTS tasks (
id INT AUTO_INCREMENT,
task VARCHAR(255),
priority VARCHAR(10),
due_date DATE,
category VARCHAR(50),
recurrence VARCHAR(10),
completed BOOLEAN DEFAULT FALSE,
notes TEXT,
archived BOOLEAN DEFAULT FALSE,
PRIMARY KEY (id)
);
""")

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

query ="INSERT INTO tasks (task,priority,due_date,category,recurrence,notes) VALUES(%s,%s,%s,%s,%s,%s,)”


cursor.execute(query, (task, priority, due_date, category, recurrence, notes))
cnx.commit()
print("Task added successfully!")
def view_tasks():
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]} - Priority: {task[2]} - Due: {task[3]} - Category: {task[4]} - Completed: {task[6]}")

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:

--- To-Do List ---


1. Add Task
2. View Tasks
3. Delete Task
4. Modify Task
5. Complete Task
6. Archive Completed Tasks
7. View Archived Tasks
8. Exit
Choose an option: 1

Enter task: Finish project report


Enter priority (High, Medium, Low): High
Enter due date (YYYY-MM-DD) or leave blank: 2024-10-01
Enter category (e.g., Work, Personal): Work
Enter recurrence (daily, weekly, monthly) or leave blank: weekly
Enter additional notes or leave blank: Remember to include financial analysis
Task added successfully!

--- To-Do List ---


1. Add Task
2. View Tasks
3. Delete Task
4. Modify Task
5. Complete Task
6. Archive Completed Tasks
7. View Archived Tasks
8. Exit
Choose an option: 2

1 - Finish project report - Priority: High - Due: 2024-10-01 - Category: Work - Completed: False

--- To-Do List ---


1. Add Task
2. View Tasks
3. Delete Task
4. Modify Task
5. Complete Task
6. Archive Completed Tasks
7. View Archived Tasks
8. Exit
Choose an option: 4

1 - Finish project report


Enter task number to modify: 1
Enter the new task description: finish project report and presentation
Enter the new priority (High, Medium, Low): Medium
Enter the new due date (YYYY-MM-DD) or leave blank: 2024-10-05
Enter the new category or leave blank: Work
Enter the new recurrence (daily, weekly, monthly) or leave blank: one-time
Enter additional notes or leave blank: include visuals in the presentation
Task modified successfully!
--- To-Do List ---
1. Add Task
2. View Tasks
3. Delete Task
4. Modify Task
5. Complete Task
6. Archive Completed Tasks
7. View Archived Tasks
8. Exit
Choose an option: 2

1 - Complete project report and submit - Priority: High - Due: 2024-09-30 - Category: Work - Completed:
True

--- To-Do List ---


1. Add Task
2. View Tasks
3. Delete Task
4. Modify Task
5. Complete Task
6. Archive Completed Tasks
7. View Archived Tasks
8. Exit
Choose an option: 6

Completed tasks archived.

--- To-Do List ---


1. Add Task
2. View Tasks
3. Delete Task
4. Modify Task
5. Complete Task
6. Archive Completed Tasks
7. View Archived Tasks
8. Exit
Choose an option: 7
1 - Complete project report and submit - Archived

--- To-Do List ---


1. Add Task
2. View Tasks
3. Delete Task
4. Modify Task
5. Complete Task
6. Archive Completed Tasks
7. View Archived Tasks
8. Exit
Choose an option: 8
Goodbye
Outputs:

1.Described Table:

2.After Entering the task:

3.After changing details (Modifying) :


4.Multiple tasks:

5.After deleting Tasks:


Bibliography:

• Python Software Foundation. "Python Documentation." Python.org, Python Software Foundation,


https://docs.python.org/3/..
• MySQL Documentation. "MySQL Reference Manual." MySQL.com, Oracle Corporation,
https://dev.mysql.com/doc/.
• MySQL. MySQL Community Server 8.0, Oracle Corporation, 2024.
https://dev.mysql.com/downloads/mysql/.
• Python. Python 3.11.4, Python Software Foundation, 2024.
https://www.python.org/downloads/..
Delhi Public School, Indira Nagar, Lucknow

Computer Science (083)

Name: Arish Mukarram Khan


Class: XII
Section: B
Roll Number: 20
Subject Teacher: Mrs. Pinkie Srivastava

You might also like