Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
1 views

source code

The document contains a Python script for a school management system that allows adding and removing students and teachers, as well as displaying them. It includes functions for database operations using MySQL and a simple text-based menu for user interaction. There are several syntax errors and typos throughout the code that need to be corrected for proper functionality.

Uploaded by

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

source code

The document contains a Python script for a school management system that allows adding and removing students and teachers, as well as displaying them. It includes functions for database operations using MySQL and a simple text-based menu for user interaction. There are several syntax errors and typos throughout the code that need to be corrected for proper functionality.

Uploaded by

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

SOURCE CODE

import mysql.connector
from getpass import getpass

# Database connection
db mysql.connector.connect
host"lacalhost",

Usereoo'
database'cbse

cursor = db.cursor)

#Function to add a new student


def add_student():
first name =input("Enter student's first name:")
last_name input("'Enter student's last name:")
roll_number int(input("Enter student's roll number:"))
cursor.execute("INSERT INTO students (first_name, last_narne, roll_number) VALUES (%s, %s, %5)",
(first_name, last_name, rol_number))
db.commit()
print("Student added successfulyl")
WFunction to remove a student
def temove student):
roll_number int(input("Enter the roll number of the student to remove:"))
cursor.execute("DELETE FROM students WHERE roll number s", (roll_number,))
db.commit()
print("Student removed successfully!")
# Function to add a new teacher
def add _teacher):
ut("Enter teacher's first name:

ter the subiect they teach: ")


Cursor.execute("INSERT
cusor.e INTO teachers (firstname, last_name, sutbject) VALUES (Ns, , Ns)",
(first rname, last_name, subject))
db,commit()
print("Teacher added successtully")

# Function to removea teacher


def remove teacher):

teacher_id =int(input[' Enter the iD of the teacher to remove:"))


cursor.execute("DELETE FROM teschers WHERE Id - 9%s", (teacher_id.)
db,commit()
print("Teacher removed successfully!")
-WELCOME TO THE SCHOOL MANAGEMENT SYrSTEM
MADE BY ØaAgHSNEH KAUR

MAIN MENU

1 Add New Student 2. Remove Student

3. Add New Teacher 4, Remove Teacher

5. Add Feedback 6. Display Students


7. Display Teachers 8. Logout

choice input("Enter your choice (1-8):")

it choice 1:
aoo_stucento

etf choicet student


add teacher)
eiif choice-4:
remove teacher()
elif cholce '5:
add feedback()
elf cholce6:
dsplay students()
elif choice7:
display_teachers()
elif choice '8:
print("Logging out "]
break
else:
print("Invalid choice. Try again.)
else
printt"Login failed. Please try again ")
elif choice '3:
print("Exiting the Schoalmanagement system, GOoDBYE)
break

You might also like