0% found this document useful (0 votes)
37 views3 pages

Student Management System Project

Video

Uploaded by

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

Student Management System Project

Video

Uploaded by

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

Student Management System

This project demonstrates how to create a Student Management System using Python and MySQL.

The system allows the user to perform CRUD operations (Create, Read, Update, Delete) on student

records.

Python Code

import mysql.connector

# Establishing connection to MySQL

def connect_to_database():

return mysql.connector.connect(

host="localhost",

user="your_username", # Replace with your MySQL username

password="your_password", # Replace with your MySQL password

database="school" # Replace with your database name

# Function to create a table

def create_table():

db = connect_to_database()

cursor = db.cursor()

cursor.execute("""

CREATE TABLE IF NOT EXISTS students (

id INT AUTO_INCREMENT PRIMARY KEY,


name VARCHAR(100),

age INT,

class VARCHAR(50)

""")

db.commit()

db.close()

# Function to insert a new student record

def insert_student(name, age, student_class):

db = connect_to_database()

cursor = db.cursor()

query = "INSERT INTO students (name, age, class) VALUES (%s, %s, %s)"

values = (name, age, student_class)

cursor.execute(query, values)

db.commit()

db.close()

print("Student record inserted successfully!")


SQL Script

CREATE DATABASE school;

USE school;

CREATE TABLE students (

id INT AUTO_INCREMENT PRIMARY KEY,

name VARCHAR(100),

age INT,

class VARCHAR(50)

);

You might also like