Hospital Appointment Management System
Class 12 Computer Science Project (Python + SQL)
1. Project Overview
This project is a Hospital Appointment Management System that allows: - Patient registration -
Doctor management - Appointment booking - Viewing appointments
The project is fully functional, easy to understand, and perfect for CBSE / ISC Class 12 practicals &
viva.
2. Technologies Used
• Python 3
• SQLite (SQL database)
• Python SQLite3 module
• Command Line Interface (CLI)
SQLite is recommended for school projects because it does not require installation.
3. Database Design
Tables Used
1. patients
2. doctors
3. appointments
SQL Schema
CREATE TABLE patients (
patient_id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT,
age INTEGER,
gender TEXT,
phone TEXT
);
CREATE TABLE doctors (
doctor_id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT,
specialization TEXT
);
1
CREATE TABLE appointments (
appointment_id INTEGER PRIMARY KEY AUTOINCREMENT,
patient_id INTEGER,
doctor_id INTEGER,
date TEXT,
time TEXT,
FOREIGN KEY(patient_id) REFERENCES patients(patient_id),
FOREIGN KEY(doctor_id) REFERENCES doctors(doctor_id)
);
4. Python Code (Main Program)
import sqlite3
conn = [Link]('[Link]')
cursor = [Link]()
# Create tables
[Link]('''CREATE TABLE IF NOT EXISTS patients (
patient_id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT,
age INTEGER,
gender TEXT,
phone TEXT
)''')
[Link]('''CREATE TABLE IF NOT EXISTS doctors (
doctor_id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT,
specialization TEXT
)''')
[Link]('''CREATE TABLE IF NOT EXISTS appointments (
appointment_id INTEGER PRIMARY KEY AUTOINCREMENT,
patient_id INTEGER,
doctor_id INTEGER,
date TEXT,
time TEXT
)''')
[Link]()
# Functions
def add_patient():
name = input("Enter patient name: ")
age = int(input("Enter age: "))
2
gender = input("Enter gender: ")
phone = input("Enter phone number: ")
[Link]("INSERT INTO patients VALUES (NULL,?,?,?,?)", (name, age,
gender, phone))
[Link]()
print("Patient added successfully")
def add_doctor():
name = input("Enter doctor name: ")
spec = input("Enter specialization: ")
[Link]("INSERT INTO doctors VALUES (NULL,?,?)", (name, spec))
[Link]()
print("Doctor added successfully")
def book_appointment():
patient_id = int(input("Enter patient ID: "))
doctor_id = int(input("Enter doctor ID: "))
date = input("Enter appointment date (DD-MM-YYYY): ")
time = input("Enter time: ")
[Link]("INSERT INTO appointments VALUES (NULL,?,?,?,?)",
(patient_id, doctor_id, date, time))
[Link]()
print("Appointment booked successfully")
def view_appointments():
[Link]('''SELECT appointment_id, [Link], [Link],
date, time
FROM appointments
JOIN patients ON appointments.patient_id =
patients.patient_id
JOIN doctors ON appointments.doctor_id =
doctors.doctor_id''')
records = [Link]()
for row in records:
print(row)
# Menu
while True:
print("\n--- Hospital Appointment System ---")
print("1. Add Patient")
print("2. Add Doctor")
print("3. Book Appointment")
print("4. View Appointments")
print("5. Exit")
choice = input("Enter choice: ")
if choice == '1':
3
add_patient()
elif choice == '2':
add_doctor()
elif choice == '3':
book_appointment()
elif choice == '4':
view_appointments()
elif choice == '5':
print("Thank you")
break
else:
print("Invalid choice")
[Link]()
5. How to Run the Project
1. Install Python 3
2. Save file as [Link]
3. Run:
python [Link]
4. Database file [Link] will be created automatically
6. How to Deploy This Project Live 🌐
OPTION 1: Replit (BEST for School Projects) ⭐⭐⭐
• Go to [Link]
• Create account
• New Repl → Python
• Paste code
• Click Run
✔ No installation ✔ Shareable link ✔ Teacher can run it
OPTION 2: PythonAnywhere
• Free Python hosting
• Upload code
• Run via console
4
OPTION 3: Convert to Web App (Advanced)
• Use Flask + MySQL
• Deploy on Render / Railway / Vercel
(Not required for Class 12 but great for extra marks)
7. Viva Questions (Important)
1. What is SQLite?
2. Difference between primary key & foreign key
3. What is CRUD?
4. Why SQL is used with Python?
5. Explain JOIN query
8. Conclusion
This project demonstrates: - Python programming - SQL database usage - Real-world application -
Proper data management
It is 100% functional, viva-safe, and teacher-friendly.
Want me to:
• Convert this into GUI (Tkinter)?
• Make Project File PDF?
• Add Login System?
• Turn it into Website?
Just say the word 😄