A command-line application to manage student grades, courses, and academic analytics using Python and PostgreSQL. Built for educators and administrators.
- 🧑🎓 CRUD Operations: Add/View Students, Courses, and Grades
- 📊 Grade Analytics: Calculate student averages and view performance trends
- 🔗 Relational Database: 3NF-normalized tables with foreign key constraints
- 🛡️ Data Integrity: Grade validation (0-100) and transaction rollbacks
- 📅 Semester Tracking: Organize grades by academic terms
- Database: PostgreSQL
- Backend: Python +
psycopg2 - Tools: pgAdmin, SQL Shell
- PostgreSQL 15+ (Download)
- Python 3.9+
-
Clone the repository:
git clone https://github.com/inner-byte/postgresql-student-tracker-cli.git cd postgresql-student-tracker-cli -
Create PostgreSQL Database:
psql -U postgres -c "CREATE DATABASE student_grades;" psql -U postgres -c "CREATE USER pg_user WITH PASSWORD 'pg_password';" psql -U postgres -c "GRANT ALL PRIVILEGES ON DATABASE student_grades TO pg_user;"
-
Initialize Schema:
psql -U pg_user -d student_grades -a -f schema.sql
-
Install Dependencies:
pip install -r requirements.txt
Start the CLI:
python main.py- Add Student
- Add Course
- Add Grade
- View Students
- View Courses
- View Grades
- Calculate Avg
- Exit
CREATE TABLE students (
student_id SERIAL PRIMARY KEY,
name VARCHAR(100) NOT NULL,
email VARCHAR(100) UNIQUE
);
CREATE TABLE courses (
course_id SERIAL PRIMARY KEY,
name VARCHAR(100) NOT NULL,
instructor VARCHAR(100)
);
CREATE TABLE grades (
grade_id SERIAL PRIMARY KEY,
student_id INT REFERENCES students(student_id) ON DELETE CASCADE,
course_id INT REFERENCES courses(course_id) ON DELETE CASCADE,
grade DECIMAL(5,2) CHECK (grade >= 0 AND grade <= 100),
semester VARCHAR(20)
);erDiagram
students ||--o{ grades : "1 to Many"
courses ||--o{ grades : "1 to Many"
students {
INT student_id PK
STRING name
STRING email
}
courses {
INT course_id PK
STRING name
STRING instructor
}
grades {
INT grade_id PK
INT student_id FK
INT course_id FK
DECIMAL grade
STRING semester
}
- Fork the project.
- Create your feature branch:
git checkout -b feature/AmazingFeature
- Commit your changes:
git commit -m 'Add some AmazingFeature' - Push to the branch:
git push origin feature/AmazingFeature
- Open a Pull Request.
Distributed under the MIT License. See LICENSE for details.
Made with ❤️ by [Ali Ahmad Sunusi] | 📧 asakrg@outlook.com