12 Projects: Python + MySQL
CBSE 2026-27 का CS project: Python file handling / Python-SQL connectivity से कुछ ठोस और उपयोगी बनाना – 2–3 students के group में, कम से कम 6 महीने पहले शुरू करके। Syllabus ख़ुद GST invoice जैसे project का उदाहरण देता है। नीचे 12 पूरे, tested projects हैं – हर एक MySQL connectivity, file handling, functions और exception handling इस्तेमाल करता है।
12 projects की list
| # | 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 का विवरण
1. School Fee Management System
School के students और monthly fee जमा का record MySQL में रखता है, fee receipt text file में बनाता है, किसी भी month के defaulters बताता है और fee register CSV में export करता है।
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 (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
School library की books और members संभालता है: issue/return और 14 दिन के बाद Rs 2 प्रति दिन fine, title/author से search, issued books की list, overdue report CSV में और catalogue का binary-file backup।
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 (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
छोटे hotel के check-in और check-out संभालता है: खाली rooms, room booking, check-out पर GST सहित bill (text file में), current guests और 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 (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
Savings/current accounts खोलता है, balance check के साथ deposit और withdrawal record करता है, mini statement दिखाता है, पूरा statement CSV में export करता है और session की recent activities का stack रखता है।
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 (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 और Appointment Management
Patients register करता है, doctors के साथ OPD appointment बुक करता है, OPD slip text file में बनाता है, किसी दिन की appointment list, visit complete और doctor-wise patients व 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 (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 और Invoice System
CBSE syllabus में सुझाया गया project: दुकान का billing system जो products और उनकी GST rates रखता है, कई items वाले invoice CGST/SGST के साथ बनाता है, हर invoice text file में save करता है और return filing के लिए tax rate-wise GST summary देता है।
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 (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
Khurja से routes के bus tickets बुक करता है, चुनी तारीख़ के लिए अगली खाली seat देता है, e-ticket text file में बनाता है, 80% refund के साथ ticket cancel करता है (cancelled PNR stack में), passenger list और 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 (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
Students और पाँच subjects के theory व practical marks रखता है, grades के साथ report card text file में बनाता है, class toppers और subject averages निकालता है और सभी report cards binary file में save करता है।
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 (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
किसी संस्था के employees रखता है और DA, HRA व PF कटौती के साथ monthly pay slips text file में बनाता है, department-wise salary bill, increment और payroll register CSV export करता है।
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 (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
Kirana दुकान का stock रखता है: purchase (stock in) और sale (stock out) entries log के साथ, negative stock रोकता है, low-stock alert देकर reorder list CSV में बनाता है और category-wise stock value व 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 (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
Menu-driven quiz game: questions MySQL में रखे हैं (CSV file से import भी हो सकते हैं), topic-wise random questions पूछे जाते हैं, गलत जवाब review stack में जाते हैं, score save होते हैं और leaderboard व topic-wise average दिखता है।
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 (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
Domestic और commercial consumers register करता है, monthly meter reading लेता है, fixed charge के साथ slab-wise bill बनाता है (text file में), payment लेता है, unpaid bills और 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 (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.
Project कैसे चलाएँ
pip install mysql-connector-python # open main.py and write your MySQL password in MYSQL_PASSWORD python main.py
Database, tables और sample data पहली बार चलाने पर अपने आप बन जाते हैं। हर folder में README.md, database.sql और असली sample_output.txt है।
Project file का format
- 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
Sample data को अपने school, शहर या किसी local दुकान (अनुमति लेकर) के data से बदलें, कम से कम एक feature अपना जोड़ें, और हर data source का reference लिखें।
