CLI Student Database — First Steps Into Python
Work Completed:
- Initialized a student database CLI and implemented basic data persistence using JSON.
- Built robust input validation (
try/except loops) to handle invalid menu choices and prevent the program from crashing on typos (like typing abc for an integer).
- Restricted range entries (e.g., age 0–20, grades 1–13) to prevent garbage data insertion.
- Expanded the menu to a full CRUD flow: Add (with duplicate detection), View, Search (case-insensitive partial match), Update, Delete (with confirmation), and Statistics.
- Implemented an auto-save routine that writes to the JSON file after every database mutation (Add, Update, Delete) to prevent data loss.
- Refactored the validation parameters into centralized constants at the top of the file to make maintenance easier.
The Struggle: Smart Edits & Empty Inputs
The biggest logic challenge was the Update feature. I didn’t want to force users to re-type a student’s age and grade if they only wanted to change one of them.
My solution was checking if the input is empty using .strip() and evaluating it dynamically:
new_age = input("New age (press Enter to keep current): ").strip()
if new_age:
database[name]["age"] = int(new_age)
If they just hit Enter, Python evaluates the empty string as falsy and safely skips the update, leaving the old value intact. It was a simple fix, but it made the CLI feel better
Next Steps:
-
Sorting data: Study how to sort dictionary outputs by name, age, or grade.
-
Grade labels: Map numerical grades to letter categories (A/B/C/D/F). So 90 would be A
-
Nested structures: Expand the schema to support multiple subjects per student.
-
Data Export: Learn the
csv module to output student lists to a spreadsheet format.
-
System Refactoring: Move the program toward Object-Oriented Programming (OOP) classes, and eventually migrate JSON file storage to a lightweight SQLite database.
Conclusion
A few hours ago this was a script that crashed on bad input and forgot your data. Now it’s a small application with validation, persistence, and a proper menu. The biggest win wasn’t any single feature — it was realizing that I can take a broken thing, isolate the problem, and fix it incrementally. That’s the actual skill. It was a great excersice to pracitce coding while I wait for my MIRA training to complete.