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

Fee Management Project Details Without Using PANDA

Uploaded by

roydeadmanx
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

Fee Management Project Details Without Using PANDA

Uploaded by

roydeadmanx
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Here's a detailed outline and explanation for a Python Project on Fee Management using

mysql.connector for database operations and csv for file handling. The project is structured
to include functionalities like managing student details, handling fee payments, generating
reports, and exporting/importing data using CSV files.

Requirements

1. Python Libraries
o mysql.connector: To interact with the MySQL database.
o csv: For file handling (import/export CSV).
2. MySQL Database
o A database named fee_management with a table students to store student
data.

Project Features

1. Add Student
Adds a new student record with name, roll number, class, and pending fees.
2. Update Fee Payment
Updates the pending fees when a payment is made.
3. View All Students
Displays all students with their details.
4. Search Student
Searches for a student by roll number or name.
5. Export to CSV
Exports the student records to a CSV file.
6. Import from CSV
Imports student data from a CSV file into the database.
7. Delete Student
Deletes a student record based on their roll number.

Project Structure
plaintext
Copy code
fee_management/
├── fee_management.py # Main script
└── requirements.txt # File to install dependencies

Database Setup

Create the fee_management database and students table using the following SQL script:
sql
Copy code
CREATE DATABASE fee_management;

USE fee_management;

CREATE TABLE students (


roll_no INT PRIMARY KEY,
name VARCHAR(100) NOT NULL,
class VARCHAR(20) NOT NULL,
pending_fees DECIMAL(10, 2)
);

Python Code

Here’s the Python script for the project:

python
Copy code
import mysql.connector
import csv

# Database Connection
def connect_to_database():
return mysql.connector.connect(
host="localhost",
user="root", # Replace with your username
password="password", # Replace with your password
database="fee_management"
)

# Add Student
def add_student(roll_no, name, student_class, pending_fees):
conn = connect_to_database()
cursor = conn.cursor()
query = "INSERT INTO students (roll_no, name, class, pending_fees)
VALUES (%s, %s, %s, %s)"
cursor.execute(query, (roll_no, name, student_class, pending_fees))
conn.commit()
conn.close()
print("Student added successfully!")

# Update Fee Payment


def update_fee_payment(roll_no, amount):
conn = connect_to_database()
cursor = conn.cursor()
query = "UPDATE students SET pending_fees = pending_fees - %s WHERE
roll_no = %s"
cursor.execute(query, (amount, roll_no))
conn.commit()
conn.close()
print("Fee updated successfully!")

# View All Students


def view_students():
conn = connect_to_database()
cursor = conn.cursor()
query = "SELECT * FROM students"
cursor.execute(query)
results = cursor.fetchall()
conn.close()
print("Roll No | Name | Class | Pending Fees")
print("---------------------------------------------")
for row in results:
print(f"{row[0]} | {row[1]} | {row[2]} | {row[3]}")
return results

# Search Student
def search_student(roll_no=None, name=None):
conn = connect_to_database()
cursor = conn.cursor()
if roll_no:
query = "SELECT * FROM students WHERE roll_no = %s"
cursor.execute(query, (roll_no,))
elif name:
query = "SELECT * FROM students WHERE name LIKE %s"
cursor.execute(query, (f"%{name}%",))
results = cursor.fetchall()
conn.close()
return results

# Export to CSV
def export_to_csv(filename):
students = view_students()
with open(filename, "w", newline="") as file:
writer = csv.writer(file)
writer.writerow(["Roll No", "Name", "Class", "Pending Fees"])
writer.writerows(students)
print(f"Data exported to {filename} successfully!")

# Import from CSV


def import_from_csv(filename):
conn = connect_to_database()
cursor = conn.cursor()
with open(filename, "r") as file:
reader = csv.reader(file)
next(reader) # Skip header
for row in reader:
query = "INSERT INTO students (roll_no, name, class,
pending_fees) VALUES (%s, %s, %s, %s)"
cursor.execute(query, row)
conn.commit()
conn.close()
print(f"Data imported from {filename} successfully!")

# Delete Student
def delete_student(roll_no):
conn = connect_to_database()
cursor = conn.cursor()
query = "DELETE FROM students WHERE roll_no = %s"
cursor.execute(query, (roll_no,))
conn.commit()
conn.close()
print("Student deleted successfully!")

# Main Menu
def main():
while True:
print("\n--- Fee Management System ---")
print("1. Add Student")
print("2. Update Fee Payment")
print("3. View All Students")
print("4. Search Student")
print("5. Export to CSV")
print("6. Import from CSV")
print("7. Delete Student")
print("8. Exit")

choice = int(input("Enter your choice: "))

if choice == 1:
roll_no = int(input("Enter Roll No: "))
name = input("Enter Name: ")
student_class = input("Enter Class: ")
pending_fees = float(input("Enter Pending Fees: "))
add_student(roll_no, name, student_class, pending_fees)
elif choice == 2:
roll_no = int(input("Enter Roll No: "))
amount = float(input("Enter Fee Payment Amount: "))
update_fee_payment(roll_no, amount)
elif choice == 3:
view_students()
elif choice == 4:
roll_no = int(input("Enter Roll No (or 0 to skip): "))
name = input("Enter Name (or press Enter to skip): ")
results = search_student(roll_no if roll_no != 0 else None,
name if name else None)
print(results)
elif choice == 5:
filename = input("Enter filename (with .csv extension): ")
export_to_csv(filename)
elif choice == 6:
filename = input("Enter filename (with .csv extension): ")
import_from_csv(filename)
elif choice == 7:
roll_no = int(input("Enter Roll No to Delete: "))
delete_student(roll_no)
elif choice == 8:
print("Exiting...")
break
else:
print("Invalid choice! Try again.")

if __name__ == "__main__":
main()

Sample Output

1. Main Menu

plaintext
Copy code
--- Fee Management System ---
1. Add Student
2. Update Fee Payment
3. View All Students
4. Search Student
5. Export to CSV
6. Import from CSV
7. Delete Student
8. Exit

2. Add Student

plaintext
Copy code
Enter Roll No: 1
Enter Name: John Doe
Enter Class: 10A
Enter Pending Fees: 1500
Student added successfully!

3. View All Students

plaintext
Copy code
Roll No | Name | Class | Pending Fees
---------------------------------------------
1 | John Doe | 10A | 1500.00

How to Run

1. Set up the MySQL database using the SQL script provided.


2. Install required libraries:

bash
Copy code
pip install mysql-connector-python

3. Run the script:

bash
Copy code
python fee_management.py

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy