Harshit 007

Download as pdf or txt
Download as pdf or txt
You are on page 1of 26

KENDRIYA VIDYALAYA NO.

2 ARMAPUR
KANPUR

COMPUTER SCIENCE PROJECT

Python Program For SCHOOL MANAGEMENT


Using MySQL

UNDER GUIDANCE:- PROGRAMED BY:-


MR. Ashok Uttam Sir HARSHIT YADAV

Sig. Class-12th A
Roll No. -09
#CONTENT

 CERTIFICATE
 ACKNOWLEDGEMENT
 REQUIREMENT
 PROJECT DETAIL
 BRIEF INTRODEUCTION OF PYTHON
 BRIEF INTRDUCTION OF MySQL
 CODING(OR PROGRAM) OF PROJECT
 OUTPUT
 BIBLIOGRAPHY
Certificate
This is certify that Computer
Science Project Title by ‘SCHOOL
MANAGEMENT’ has been
successfully completed
by“ Harshit Yadav” Of class XII-A
bearing Roll No. 09 under the
guidance of Mr. Ashok Uttam
(Subject Teacher). During
academic session 2023-2024 as per
the guidelines issued by CBSE.

Teacher’s Signature
ACKNOWLEDGEMENT

I would like to express my special thanks of


gratitude to my teacher MR. Ashok Uttam,
who gave me the golden opportunity to do
this wonderful project of COMPUTER SCIENCE.

The Only One Who helped me in Doing the


Programming .Form His Help, I came to know
about so many new things such as Modules,
Built-in-Functions & many more . I am really
thankful to Him.

Secondary I would also like to thank my


parents who helped me a lot in Research &
finalizing this project within the limited time
frame.

HARSHIT YADAV
XIIth A
REQUIREMENTS

Hardware

 Printing Device to print the


project report.
 Compact Disc.
 Ram 2GB.
 Hard Disk 512Gb.
Software

 Operating system Windows 7 , 8 , 10


 Python 3.10(IDLE 3.10.7 64-bits) for
execution of program.
 MS Word for Report
Presentation (doc.
File)
PROJECT
DETAILS
To build This project we are going to use
the ‘MySQL’ . we use different built –in-
function and created functions to execute
program.
The aim of this project is to gather the
detail from the user and mainupulate it .
This project help to store detail of student
and staff , also user edit the detail
A BRIEF INTRODUCTION OF PYTHON

Python is a widely used general-purpose, high-level


programming language. It was initially designed by
Guido van Rossum in 1991 and developed by Python
Software Foundation. It was mainly developed for
emphasis on code readability, and its syntax allows
programmers to express concepts in fewer lines of code.
⮚ Python laid its foundation in the late 1980s.
⮚ The implementation of Python was started in
the December 1989 by Guido Van Rossum at
CWI in Netherland.
⮚ In 1994, Python 1.0 was released with new
features like: lambda, map, filter, and reduce.
⮚ Python 2.0 added new features like: list
comprehensions, garbage collection system.
⮚ On December 3, 2008, Python 3.0 (also called
"Py3K") was released. It was designed to rectify
fundamental flaw of the language.
A BRIEF INTRODUCTION OF MYSQL

MySQL was created by a Swedish


company, MySQL AB, founded by David Axmark, Allan
Larsson and Michael "Monty" Widenius in 1995.
MySQL Features:

o Relational Database Management System


(RDBMS): MySQL is a relational database
management system.
o Easy to use: MySQL is easy to use. You have to get
only the basic knowledge of SQL. You can build and
interact with MySQL with only a few simple SQL
statements.
o It is secure: MySQL consist of a solid data security
layer that protects sensitive data from intruders.
Passwords are encrypted in MySQL.
o Client/ Server Architecture: MySQL follows a client
/server architecture. There is a database server
(MySQL) and arbitrarily many clients (application
programs), which communicate with the server; that
is, they query data, save changes, etc.
o Free to download: MySQL is free to use and you
can download it from MySQL official website.
o It is scalable: MySQL can handle almost any
amount of data, up to as much as 50 million rows or
more. The default file size limit is about 4 GB.
However, you can increase this number to a
theoretical limit of 8 TB of data.

o Compatible on many operating systems: MySQL


is compatible to run on many operating systems, like
Novell NetWare, Windows* Linux*, many varieties of
UNIX* (such as Sun* Solaris*, AIX, and DEC* UNIX),
OS/2, FreeBSD*, and others. MySQL also provides
a facility that the clients can run on the same
computer as the server or on another computer
(communication via a local network or the Internet).
o Allows roll-back: MySQL allows transactions to be
rolled back, commit and crash recovery.
--------------------------------PROGRAM-----------------------------

import mysql.connector

# Connect to MySQL database


db = mysql.connector.connect(
host="localhost",
user="root",
password="root",
database="SCHOOL_MANAGEMENT07"
)

# Create a cursor object to interact with the database


cursor = db.cursor()

# Create tables for students and staff


cursor.execute("""
CREATE TABLE IF NOT EXISTS students (
student_id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) NOT NULL,
age INT,
grade VARCHAR(10),
address VARCHAR(255),
contact_number VARCHAR(15)
)
""")

cursor.execute("""
CREATE TABLE IF NOT EXISTS staff (
staff_id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) NOT NULL,
age INT,
position VARCHAR(50),
department VARCHAR(50),
contact_number VARCHAR(15)
)
""")

# Function to add a new student


def add_student(name, age, grade, address,
contact_number):
sql = "INSERT INTO students (name, age, grade,
address, contact_number) VALUES
(%s, %s, %s, %s, %s)"
values = (name, age, grade, address, contact_number)
cursor.execute(sql, values)
db.commit()
print("Student added successfully!")

# Function to add a new staff member


def add_staff(name, age, position, department,
contact_number):
sql = "INSERT INTO staff (name, age, position,
department, contact_number)
VALUES (%s, %s, %s, %s, %s)"
values = (name, age, position, department, contact_number)
cursor.execute(sql, values)
db.commit()
print("Staff member added successfully!")
# Function to update student information
def update_student(student_id, name, age, grade, address,
contact_number):
sql = "UPDATE students SET name=%s, age=%s,
grade=%s, address=%s,
contact_number=%s WHERE student_id=%s"
values = (name, age, grade, address, contact_number,
student_id)
cursor.execute(sql, values)
db.commit()
print("Student information updated
successfully!")

# Function to update staff member information


def update_staff(staff_id, name, age, position, department,
contact_number):
sql = "UPDATE staff SET name=%s, age=%s,
position=%s, department=%s,
contact_number=%s WHERE staff_id=%s"
values = (name, age, position, department, contact_number,
staff_id)
cursor.execute(sql, values)
db.commit()
print("Staff member information updated
successfully!")

# Function to delete a student


def delete_student(student_id):
sql = "DELETE FROM students WHERE
student_id=%s"
values = (student_id,)
cursor.execute(sql, values)
db.commit()
print("Student deleted successfully!")

# Function to delete a staff member


def delete_staff(staff_id):
sql = "DELETE FROM staff WHERE staff_id=%s"

values = (staff_id,)
cursor.execute(sql, values)
db.commit()
print("Staff member deleted successfully!")

# Function to view all students


def view_students():
cursor.execute("SELECT * FROM students")
students = cursor.fetchall()

if not students:
print("No students found.")
else:
print("Student ID | Name | Age | Grade | Address |
Contact Number")
print("-----------------------------------------------------------------
-------------")
for student in students:
print(f"{student[0]:<11} | {student[1]:<12} |
{student[2]:<3} | {student[3]:<5} |
{student[4]:<21} | {student[5]:<15}")

# Function to view all staff members


def view_staff():
cursor.execute("SELECT * FROM staff")
staff_members = cursor.fetchall()

if not staff_members:
print("No staff members found.")
else:
print("Staff ID | Name | Age | Position | Department |
Contact
Number")

print("-----------------------------------------------------------------
--------------------------
--")
for staff_member in staff_members:
print(f"{staff_member[0]:<9} |
{staff_member[1]:<12} | {staff_member[2]:<3} |
{staff_member[3]:<21} | {staff_member[4]:<21} |
{staff_member[5]:<15}")

# Main program loop


while True:
print("\nSchool Management System")
print("1. Add Student")
print("2. Add Staff Member")
print("3. Update Student Information")
print("4. Update Staff Member Information")
print("5. Delete Student")
print("6. Delete Staff Member")
print("7. View Students")
print("8. View Staff Members")
print("9. Exit")

choice = input("Enter your choice (1-9): ")

if choice == '1':
name = input("Enter student name: ")
age = int(input("Enter student age: "))
grade = input("Enter student grade: ")
address = input("Enter student address: ")
contact_number = input("Enter student contact
number: ")
add_student(name, age, grade, address, contact_number)

elif choice == '2':


name = input("Enter staff member name: ")
age = int(input("Enter staff member age: "))
position = input("Enter staff member position: ")
department = input("Enter staff member department:
")
contact_number = input("Enter staff member contact
number: ")
add_staff(name, age, position, department, contact_number)

elif choice == '3':


student_id = int(input("Enter student ID to update:
"))
name = input("Enter new name: ")
age = int(input("Enter new age: "))
grade = input("Enter new grade: ")
address = input("Enter new address: ")
contact_number = input("Enter new contact number:
")
update_student(student_id, name, age, grade, address,
contact_number)

elif choice == '4':


staff_id = int(input("Enter staff member ID to update:
"))
name = input("Enter new name: ")
age = int(input("Enter new age: "))
position = input("Enter new position: ")
department = input("Enter new department: ")
contact_number = input("Enter new contact number:
")
update_staff(staff_id, name, age, position, department,
contact_number)

elif choice == '5':


student_id = int(input("Enter student ID to delete:
"))

delete_student(student_id)
elif choice == '6':
staff_id = int(input("Enter staff member ID to delete:
"))
delete_staff(staff_id)

elif choice == '7':


view_students()

elif choice == '8':


view_staff()

elif choice == '9':


print("Exiting program. Goodbye!")
break

else:
print("Invalid choice. Please enter a number between 1
and 9.")

*******************PROGRAM END******************
-------------------------------OUTPUT-------------------------------

FOR CHOICE ‘1’ & ‘2’ :-


FOR CHOICE ‘3’ & ‘4’ :-
FOR CHOICE ‘5’ & ‘6’ :-
FOR CHOICE ‘7’ & ‘8’ :-
BIBLIOGRAPHY

 https://www.google.com/

 Computer Science
Notebook(Classwork Copy)

You might also like