12 Projects: Python + MySQL
The CBSE 2026-27 CS project: create something tangible and useful using Python file handling / Python-SQL connectivity, in a group of 2–3 students, started at least 6 months before submission. The syllabus itself suggests a GST-invoice style project. Below are 12 complete, tested projects – each uses MySQL connectivity, file handling, functions and exception handling.
List of 12 projects
| # | Project | MySQL database |
|---|---|---|
| 1 | School Fee Management System | cs_fee_project |
| 2 | Library Management System | cs_library_project |
| 3 | Hotel Room Booking System | cs_hotel_project |
| 4 | Bank Account Management System | cs_bank_project |
| 5 | Hospital Patient and Appointment Management | cs_hospital_project |
| 6 | GST Billing and Invoice System | cs_gst_project |
| 7 | Bus Ticket Reservation System | cs_bus_project |
| 8 | Student Report Card System | cs_reportcard_project |
| 9 | Employee Payroll System | cs_payroll_project |
| 10 | Kirana Store Inventory Management System | cs_inventory_project |
| 11 | Computer Science Quiz Game with Leaderboard | cs_quiz_project |
| 12 | Electricity Billing System | cs_electricity_project |
Project details
1. School Fee Management System
Keeps student records and monthly fee deposits of a school in MySQL, prints a fee receipt to a text file, lists fee defaulters for any month and exports the fee register to a CSV file.
Menu: Add a student · Show all students · Collect fee & print receipt · Fee history of a student · Fee defaulters of a month · Class-wise collection · Export fee register (CSV)
Tables: student(adm_no, name, class, phone, monthly_fee); fee(receipt_no, adm_no, month, amount, paid_on)
Viva questions with answers
- Why is AUTO_INCREMENT used for receipt_no?
MySQL gives the next receipt number itself; cursor.lastrowid returns it after the INSERT. - How are defaulters found?
Admission numbers that paid for the month are put in a Python set; students not in this set are defaulters. - Why is commit() needed after INSERT?
Without commit() the change is not saved permanently in the database. - Which file modes are used?
"w" for the text receipt and the CSV register (newline="" for csv). - Why are %s placeholders used instead of joining strings?
The connector inserts values safely, avoiding errors with quotes and SQL injection.
2. Library Management System
Manages books and members of a school library: issue and return with automatic fine (Rs 2 per day after 14 days), search by title or author, list of books currently issued, overdue report in CSV and a binary-file backup of the catalogue.
Menu: Add a book · Search books · Issue a book · Return a book · Books currently issued · Overdue report (CSV) · Backup catalogue (binary file)
Tables: book(book_id, title, author, category, copies); member(member_id, name, class); issue(issue_id, book_id, member_id, issue_date, return_date, fine)
Viva questions with answers
- How is the fine calculated?
Days kept minus 14 free days; if positive, multiplied by Rs 2. Date subtraction gives a timedelta whose .days is used. - Why is return_date NULL for issued books?
NULL means the book has not come back; IS NULL finds pending issues. - Which join is used in "Books currently issued"?
An equi-join of issue, book and member on book_id and member_id. - How does pickle store the catalogue?
pickle.dump() writes each dictionary to a binary file; pickle.load() reads them back until EOFError. - Why is the copies column updated on issue and return?
To keep stock correct: copies - 1 when issued, + 1 when returned.
3. Hotel Room Booking System
Handles room check-in and check-out for a small hotel: shows free rooms, books a room, calculates the bill with GST at check-out and saves it as a text file, lists current guests and shows room-type-wise revenue.
Menu: Show free rooms · Check-in (book a room) · Check-out & bill · Current guests · Revenue by room type · Export bookings (CSV)
Tables: room(room_no, room_type, rate, status); booking(booking_id, guest, phone, room_no, check_in, check_out, amount)
Viva questions with answers
- How is the number of nights calculated?
check_out - check_in gives a timedelta; .days is the number of nights (minimum 1). - Why is the room status updated?
To show only free rooms for booking: Booked at check-in, Free again at check-out. - What does IS NULL find in this project?
Bookings whose check_out is still empty, i.e. guests staying in the hotel now. - Where is the bill stored?
In a text file output/bill_booking_<id>.txt opened in "w" mode. - Which SQL clause gives revenue by room type?
GROUP BY room_type with SUM(amount) on the joined tables.
4. Bank Account Management System
Opens savings/current accounts, records deposits and withdrawals with balance checks, shows the mini statement, exports a full statement to CSV and keeps a stack of recent activities of the session.
Menu: Open new account · Deposit · Withdraw · Mini statement (last 5) · Export statement (CSV) · Bank summary · Recent activity (stack)
Tables: account(acc_no, name, acc_type, balance, opened); txn(txn_id, acc_no, txn_date, kind, amount, balance_after)
Viva questions with answers
- How is the minimum balance rule enforced?
Before a withdrawal the new balance is checked; if it is below Rs 1000 a ValueError is raised and handled in except. - Why are two tables used?
account stores the current balance; txn stores every deposit/withdrawal for the statement. - How is the recent activity a stack?
Each action is appended (push) to a list and displayed in reverse, so the latest is on top. - What does IFNULL(MAX(acc_no), 5000) + 1 do?
Gives the next account number; if the table is empty MAX is NULL, so 5000 is used. - Why does the statement export use newline=""?
The csv module needs it to avoid blank lines between rows on Windows.
5. Hospital Patient and Appointment Management
Registers patients, books OPD appointments with doctors, prints an OPD slip to a text file, shows the appointment list of a day, marks visits complete and gives doctor-wise patient counts and fee collection.
Menu: Register patient · Show doctors · Book appointment & OPD slip · Appointment list of a day (CSV) · Mark appointment visited · Doctor-wise report
Tables: doctor(doc_id, name, dept, fee); patient(pid, name, age, gender, phone); appointment(app_id, pid, doc_id, app_date, token, status)
Viva questions with answers
- How is the token number decided?
COUNT(*) of the doctor's appointments on that date plus 1. - Which three tables are joined for the day list?
appointment, patient and doctor using pid and doc_id (equi-join). - What does cur.rowcount tell after UPDATE?
How many rows were changed; 1 means the appointment was found and updated. - Why is AUTO_INCREMENT used for pid?
MySQL gives a unique patient id automatically; lastrowid returns it. - Which files does the project create?
A text OPD slip for every appointment and a CSV list for each day.
6. GST Billing and Invoice System
The project idea suggested in the CBSE syllabus: a shop billing system that stores products with their GST rates, creates multi-item invoices with CGST/SGST split, saves each invoice as a text file and prints a GST summary grouped by tax rate for filing returns.
Menu: Show products · Add product · Create invoice · View all invoices · GST summary by rate (CSV) · Category-wise sales
Tables: product(code, name, category, price, gst_rate); invoice(inv_no, customer, inv_date, taxable, gst, total); invoice_item(inv_no, code, qty, price, gst_rate)
Viva questions with answers
- How is GST calculated for an item?
quantity x price x GST rate / 100; the invoice adds it for all items. - Why is GST split into CGST and SGST?
For a sale within the same state, half of GST goes to the Centre (CGST) and half to the State (SGST). - Why is invoice_item a separate table?
One invoice can have many items; storing items separately avoids repeating invoice details. - Which query groups transactions by tax rate?
SELECT gst_rate, SUM(qty*price), SUM(qty*price*gst_rate/100) FROM invoice_item GROUP BY gst_rate. - How is the invoice number generated?
IFNULL(MAX(inv_no), 0) + 1 gives the next number.
7. Bus Ticket Reservation System
Books bus tickets for routes from Khurja, allots the next free seat for the chosen date, prints the e-ticket to a text file, cancels tickets with an 80% refund (cancelled PNRs kept in a stack) and shows passenger lists and route-wise collection.
Menu: Show buses · Seat availability · Book ticket · Cancel ticket · Cancelled in this session (stack) · Passenger chart (CSV) · Route-wise collection
Tables: bus(bus_no, route, departure, seats, fare); ticket(pnr, bus_no, passenger, age, seat_no, travel_date, status)
Viva questions with answers
- How is the seat number allotted?
Booked seats for the bus and date are collected in a set; the first seat number not in the set is given. - Why is a ticket not deleted on cancellation?
Its status is changed to Cancelled so that the record and refund history remain. - Where is the stack used?
Cancelled PNRs are pushed with append(); they are shown in reverse so the latest is on top. - Which query calculates route-wise collection?
A join of ticket and bus with GROUP BY route and SUM(fare) for booked tickets. - What happens if the same PNR is cancelled twice?
The SELECT finds no booked ticket, so a message is shown and nothing changes.
8. Student Report Card System
Stores students and their theory and practical marks in five subjects, generates a formatted report card with grades (CBSE 9-point style) as a text file, finds class toppers and subject averages, and saves all report cards to a binary file.
Menu: Add student with marks · Re-enter marks of a student · Print report card · Class toppers · Subject-wise average · Archive all cards (binary + CSV)
Tables: student(roll, name, class); marks(roll, subject, theory, practical)
Viva questions with answers
- Why does the marks table have a composite primary key?
(roll, subject) together is unique: one student has one row per subject. - How is the grade decided?
The function grade() checks the total against limits 91, 81, 71 ... and returns A1, A2, B1 ... - Which SQL finds the class topper?
SUM(theory + practical) grouped by student and ordered in descending order of total. - What is stored in the binary file?
One dictionary per student (report card) written with pickle.dump(). - How is invalid input handled?
read_int() repeats on ValueError, and the marks loop repeats until marks are in range.
9. Employee Payroll System
Maintains employees of an organisation and generates monthly pay slips with DA, HRA and PF deductions as text files, gives department-wise salary bills, applies increments and exports the payroll register to CSV.
Menu: Add employee · List employees · Generate pay slips for a month · Department-wise salary bill · Give increment · Export payroll register (CSV)
Tables: employee(emp_id, name, designation, dept, basic, join_date); payslip(slip_id, emp_id, month, basic, da, hra, pf, net)
Viva questions with answers
- How is net salary calculated?
Basic + DA (50%) + HRA (20%) - PF (12% of basic + DA). - How does the program stop duplicate pay slips?
It counts rows of that month in payslip; if more than zero it does not generate again. - Which SQL gives the department-wise bill?
Join of employee and payslip with GROUP BY dept and SUM of gross, PF and net. - How is an increment applied to one department?
UPDATE employee SET basic = ROUND(basic * (1 + pct/100)) WHERE dept = %s. - Why is each pay slip a separate text file?
So it can be printed or mailed to that employee; the file name has month and employee id.
10. Kirana Store Inventory Management System
Keeps the stock of a grocery shop: purchase (stock in) and sale (stock out) entries with a log, prevents negative stock, raises a low-stock alert and writes a reorder list to CSV, and shows category-wise stock value and expected profit.
Menu: Show stock · Add new item · Purchase (stock in) · Sale (stock out) · Reorder list (CSV) · Category-wise stock value · Stock movement log · Save stock snapshot (binary)
Tables: item(code, name, category, qty, reorder_level, cost, mrp); stock_log(log_id, code, log_date, kind, qty)
Viva questions with answers
- How is negative stock prevented?
Before a sale the requested quantity is compared with qty in stock; if larger, the sale is refused. - What is the reorder level?
A minimum quantity; when stock falls to it or below, the item appears in the reorder list. - How is the order quantity decided?
Enough to bring the stock up to twice the reorder level: 2 x level - stock. - Why keep a separate stock_log table?
It records every purchase and sale with date, so stock changes can be checked later. - Which SQL gives category-wise stock value?
SELECT category, SUM(qty*cost) ... GROUP BY category.
11. Computer Science Quiz Game with Leaderboard
A menu-driven quiz game: questions are stored in MySQL (and can be imported from a CSV file), a random set is asked topic-wise, wrong answers are pushed on a review stack, scores are saved and a leaderboard and topic-wise averages are shown.
Menu: Play quiz · Add a question · Import questions from CSV · Leaderboard (CSV) · Topic-wise statistics
Tables: question(qid, topic, question, opt_a, opt_b, opt_c, opt_d, answer); score(sid, player, topic, score, total, played_on)
Viva questions with answers
- How are questions chosen randomly?
random.sample(pool, n) picks n different questions from the topic. - How is the stack used?
Every wrongly answered question is pushed; after the quiz they are popped and shown for revision. - How does CSV import avoid duplicates?
Before inserting, it checks with COUNT(*) whether the same question text already exists. - How is the leaderboard ordered?
By percentage score in descending order, then by date. - What does zip("abcd", options) do?
It pairs each letter with its option so they can be printed together.
12. Electricity Billing System
Registers domestic and commercial consumers, records monthly meter readings, calculates slab-wise bills with fixed charge, prints the bill to a text file, accepts payments, lists unpaid bills and shows month-wise collection.
Menu: Register consumer · Enter reading & generate bill · Pay bill · Unpaid bills (CSV) · Month-wise collection
Tables: consumer(cons_no, name, address, category, meter_no); reading(read_id, cons_no, month, prev_reading, curr_reading, units, amount, paid)
Viva questions with answers
- How is a slab-wise bill calculated?
Units in each slab are multiplied by that slab's rate and added; then the fixed charge is added. - Where does the previous reading come from?
From the last reading row of that consumer (ORDER BY read_id DESC LIMIT 1); 0 for a new consumer. - How does the program check a wrong reading?
If the current reading is less than the previous one, the bill is not generated. - Which query gives month-wise collection?
GROUP BY month with SUM(amount) and a CASE expression to add only paid bills. - Why is paid stored as Y/N?
It is a simple flag to find unpaid bills (paid = 'N') and mark them paid with UPDATE.
How to run a project
pip install mysql-connector-python # open main.py and write your MySQL password in MYSQL_PASSWORD python main.py
The database, tables and sample data are created automatically on the first run. Every folder has README.md, database.sql and a real sample_output.txt.
Format of the project file
- Cover page
- Certificate
- Acknowledgement
- Index
- Introduction (real problem chosen)
- Objectives
- Hardware & software requirements
- Concepts used
- Database design (tables)
- Source code
- Output screenshots
- Limitations & future scope
- Bibliography / references
Replace the sample data with data from your own school, town or a local shop (with permission), add at least one feature of your own, and write the source of every dataset.
