Skip to content

divyanshu1004/Student_management_system

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 

Repository files navigation

School Management System - Setup and Run Guide

Prerequisites

1. Install Python

  • Download Python 3.7+ from python.org
  • Ensure Python is added to your system PATH

2. Install MySQL Database

  • Download and install MySQL from mysql.com
  • Or use alternatives like XAMPP, WAMP, or cloud services like AWS RDS

3. Install Required Python Package

pip install mysql-connector-python

Database Setup

1. Create Database and Tables

First, create your database and tables. Here's the SQL schema:

-- Create database
CREATE DATABASE school_management;
USE school_management;

-- Create tables
CREATE TABLE parents (
    id INT PRIMARY KEY,
    name VARCHAR(100) NOT NULL,
    phone VARCHAR(20),
    email VARCHAR(100)
);

CREATE TABLE students (
    id INT PRIMARY KEY,
    name VARCHAR(100) NOT NULL,
    grade VARCHAR(20),
    email VARCHAR(100),
    parent_id INT,
    FOREIGN KEY (parent_id) REFERENCES parents(id)
);

CREATE TABLE subjects (
    id INT PRIMARY KEY,
    name VARCHAR(100) NOT NULL,
    department_id INT
);

CREATE TABLE teachers (
    id INT PRIMARY KEY,
    name VARCHAR(100) NOT NULL,
    subject_id INT,
    email VARCHAR(100),
    FOREIGN KEY (subject_id) REFERENCES subjects(id)
);

CREATE TABLE classrooms (
    id INT PRIMARY KEY,
    room_number VARCHAR(20) NOT NULL,
    capacity INT
);

CREATE TABLE classes (
    id INT PRIMARY KEY,
    name VARCHAR(100) NOT NULL,
    teacher_id INT,
    classroom_id INT,
    FOREIGN KEY (teacher_id) REFERENCES teachers(id),
    FOREIGN KEY (classroom_id) REFERENCES classrooms(id)
);

CREATE TABLE enrollments (
    student_id INT,
    class_id INT,
    PRIMARY KEY (student_id, class_id),
    FOREIGN KEY (student_id) REFERENCES students(id),
    FOREIGN KEY (class_id) REFERENCES classes(id)
);

CREATE TABLE grades (
    student_id INT,
    class_id INT,
    grade VARCHAR(5),
    PRIMARY KEY (student_id, class_id),
    FOREIGN KEY (student_id) REFERENCES students(id),
    FOREIGN KEY (class_id) REFERENCES classes(id)
);

CREATE TABLE attendance (
    id INT AUTO_INCREMENT PRIMARY KEY,
    student_id INT,
    class_id INT,
    date DATE,
    status ENUM('Present', 'Absent'),
    FOREIGN KEY (student_id) REFERENCES students(id),
    FOREIGN KEY (class_id) REFERENCES classes(id)
);

Configuration

Update Database Credentials

In the main() function, update the DB_CONFIG dictionary with your actual database credentials:

DB_CONFIG = {
    'host': 'localhost',           # Your MySQL host (usually localhost)
    'user': 'your_mysql_username', # Your MySQL username (e.g., 'root')
    'password': 'your_password',   # Your MySQL password
    'database': 'school_management' # Database name you created
}

Example Configuration:

DB_CONFIG = {
    'host': 'localhost',
    'user': 'root',
    'password': 'mypassword123',
    'database': 'school_management'
}

How to Run

Method 1: Command Line

  1. Save the Python code as school_management.py
  2. Open terminal/command prompt
  3. Navigate to the file directory:
    cd path/to/your/file
  4. Run the program:
    python school_management.py

Method 2: IDE/Code Editor

  1. Open the file in your preferred IDE (VS Code, PyCharm, etc.)
  2. Update the database configuration
  3. Run the file directly from your IDE

First-Time Setup Steps

1. Start with Parents

Since students reference parents, add parents first:

  • Choose option 2 (Insert data)
  • Select 9 (Parents)
  • Add parent information

2. Add Subjects and Classrooms

  • Add subjects (option 3)
  • Add classrooms (option 5)

3. Add Teachers

  • Teachers reference subjects, so add them after subjects

4. Add Classes

  • Classes reference teachers and classrooms

5. Add Students

  • Students reference parents

6. Create Enrollments, Grades, and Attendance

  • These reference students and classes

Usage Examples

Example Run Session:

========================================
     SCHOOL MANAGEMENT SYSTEM
========================================
1. View data from a table
2. Insert data into a table
3. Update a record
4. Modify table attributes (add/drop column)
5. Exit
----------------------------------------
Enter your choice (1-5): 2

Select the table you want to insert data into:
1. Students
2. Teachers
3. Subjects
4. Classes
5. Classrooms
6. Enrollments
7. Grades
8. Attendance
9. Parents
Enter your choice (1-9): 9

Enter parent ID: 1
Enter parent name: John Smith
Enter phone number: +1234567890
Enter email address: [email protected]

Troubleshooting

Common Issues:

  1. "No module named 'mysql.connector'"

    pip install mysql-connector-python
  2. "Access denied for user"

    • Check your MySQL username and password
    • Ensure MySQL service is running
    • Grant proper privileges to your MySQL user
  3. "Unknown database"

    • Make sure you've created the database
    • Check database name spelling
  4. "Table doesn't exist"

    • Run the SQL schema to create all tables
    • Check table names match exactly
  5. Foreign key constraint errors

    • Insert data in the correct order (parents before students, etc.)
    • Ensure referenced IDs exist

Testing Database Connection:

You can test your database connection separately:

import mysql.connector

try:
    connection = mysql.connector.connect(
        host='localhost',
        user='your_username',
        password='your_password',
        database='school_management'
    )
    print("Connection successful!")
    connection.close()
except Exception as e:
    print(f"Connection failed: {e}")

Security Notes

  • Never hardcode passwords in production
  • Use environment variables or config files for sensitive data
  • Consider using connection pooling for production applications
  • Implement proper user authentication and authorization

Next Steps

Once running successfully, you can:

  • Add more validation rules
  • Implement data export features
  • Add reporting capabilities
  • Create a web interface
  • Add backup and restore functionality

About

A menu - driven student management system created using python and mysql

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages