h College, Mu
ing zaff
S
ng at a
rp
La
ur
(Run under BRABU Bihar University)
A Mini Project Report on
Ambulance Booking System
For Python (502 and 506)
Name: Krishan Kumar
Roll: 64
University Roll: 226061
Session: 2022 – 25
Reg. No.: 133201119406422/22
Guided By: Mr. Ravikant Sir
Submitted to: Department of B.C.A., Langat Singh
College, Muzaffarpur, Bihar
Content
[Link]. Content Page No.
1. Acknowledgement 1
2. Declaration 2
3. Project Report 3-4
4. Hardware and Software 5
Requirements
5. MySQL Schema 6
9. Project Scope 7
10. Future Enhancement 8
11. Method 9
12. User Guide 10-11
13. Source Code 12-15
14. Output 16
15. Testing 17-18
16. Maintenance 19
17. Bibliography 20
Acknowledgement
I would like to express my sincere gratitude to my Principal
Prof. Dr. O.P. Roy Sir and my Teacher Mr. Ravikant Sir for
their invaluable guidance, support, and encouragement
throughout the course of this project. Their expertise and
feedback have been instrumental in the completion of this
project.
I am also grateful to the officials of Department of B.C.A.,
Langat Singh College for providing the resources and
facilities needed to complete this work. My heartfelt thanks
go to my friends and family for their constant support and
motivation.
Lastly, I wish to thank everyone who contributed directly or
indirectly to the successful completion of this project.
Thank you.
Declaration
I, Krishan Kumar, hereby declare that the mini project entitled
"Online Quiz Application" submitted in partial fulfilment of the
requirements for BCA at Langat Singh College, Muzaffarpur is
entirely my own work, conducted under the guidance of Mr.
Ravikant Sir.
I affirm that:
1. The contents of this project report are original and have not
been submitted, in part or in whole, for any other degree or
qualification.
2. Any sources of information used in this project report have
been properly acknowledged and referenced.
3. The experiments, analyses, and findings presented in this
report are genuine and have not been manipulated or falsified
in any manner.
4. Any assistance received from individuals or institutions
during the course of this project has been duly acknowledged.
I understand that any act of plagiarism or academic dishonesty in
this project would constitute a breach of academic integrity and
could lead to disciplinary action.
Krishan Kumar
Date:
Project Report:
Ambulance Booking System in Python
Introduction:
The Ambulance Booking System is a desktop-based
application that allows users to book an ambulance service
through a user-friendly graphical interface. The system is
developed using Python with the Tkinter library for the GUI
and MySQL for database management. This project aims to
simplify the process of booking ambulances for patients by
collecting essential information and storing it in a database
for easy retrieval and management.
▪ Objective:
• Provide a user-friendly interface for users to book
ambulance services.
• Store the booking details in a MySQL database for
efficient record-keeping.
• Enable quick retrieval and management of bookings.
System Functionality:
▪ User Input Validation:
• The system checks for missing fields and prompts
the user to fill in all necessary details.
▪ Data Storage:
• Saves the booking details to the MySQL database.
▪ Error Handling:
• Displays appropriate error messages for database
connection failures or missing input data.
▪ Database Connectivity:
• The function connect_db() establishes a connection
to the MySQL database using the [Link]
library.
Hardware and Software
Requirements
Hardware Requirements:
• Processor: Intel Core i3 or above.
• RAM: 2 GB or higher.
• Hard Disk: 100 MB of Free space.
Software Requirements:
• Python 3.1.11 or above.
• MySQL Server.
• MySQL Connector Library ([Link]).
• Tkinter (comes pre-installed with Python).
MySQL Schema
Database Creation:
CREATE DATABASE ambulance_booking;
-- Use the database
USE ambulance_booking;
-- Create the bookings table
CREATE TABLE bookings (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100) NOT NULL,
contact VARCHAR(15) NOT NULL,
address VARCHAR(255) NOT NULL,
ambulance_type VARCHAR(50) NOT NULL,
booking_time TIMESTAMP DEFAULT
CURRENT_TIMESTAMP
);
Project Scope
Introduction:
The Ambulance Booking System is designed to simplify the
process of booking ambulances for emergency or non-
emergency situations. It serves as a quick and efficient way
for users to provide their personal details and request an
ambulance, while ensuring the information is stored securely
in a database for further processing.
Limitations:
• The system only checks for empty fields. It does not
validate input formats for contact numbers, addresses, or
name lengths.
• The system does not check whether the selected type of
ambulance is available at the time of booking,
potentially leading to overbooking.
• Users are not required to create an account or log in.
Therefore, there is no user authentication or
management of personal booking history.
• The system does not include any payment functionality
for ambulance services, which might be necessary for
users in a real-world application.
Future Enhancement
• Adding a feature to view or cancel bookings.
• Implementing email or SMS notifications upon
successful booking.
• Integrating a more detailed ambulance tracking system.
• Enhancing the user interface for a better user experience.
• Integrating GPS-based tracking for real-time location
updates on the booked ambulance.
• Allowing users to pay for the ambulance service directly
through the application.
• Expanding the application to mobile platforms
(Android/iOS) or web-based systems.
Method
Database Connection connect_db():
• This method is used to establish a connection with the
MySQL database. It ensures that the system can
communicate with the database to perform operations
such as inserting or retrieving data.
Application Design:
• Use Python's Tkinter library to create a simple and
intuitive GUI for ambulance booking interaction.
Backend Development book_ambulance():
• This method handles the booking process for the
ambulance. It collects user input from the form,
validates the data, and inserts it into the bookings table
in the MySQL database.
User Guide
Installation:
1. Ensure that Python 3.1.11 or above is installed on your
system.
2. Install the required libraries using pip:
pip install mysql-connector-python
3. Set up the MySQL database:
• Create a database named ambulance_booking.
• Execute the provided SQL schema to create the
necessary tables.
4. Download and run the application script.
Getting Started:
1. Set up the MySQL database by creating a database
named ambulance_booking with the following tables:
• bookings: To store booking details.
2. Download and run the [Link] script using
Python.
Booking an Ambulance:
1. Enter your name.
2. Enter your contact number.
3. Enter the pickup address.
4. Select the type of Ambulance:
• Basic
• Advanced
• ICU
• Neonatal
Submit Your Booking:
1. Click the "Book Ambulance" button at the bottom of the
form.
2. The system will check for any missing information. If all
fields are correctly filled, it will attempt to save your
booking in the database.
Viewing Success Or Error Messages:
1. If the booking is successful, a pop-up message will
appear stating:
Success: Ambulance booked successfully!
2. If there are any missing fields, an error message will
appear:
Input Error: All fields are required!
3. If there is a problem with the database connection, the
following message will appear:
Database Error: <specific error message>
Source Code
import tkinter as tk
from tkinter import messagebox
import [Link]
# Connect to MySQL database
def connect_db():
return [Link](
host='localhost',
user='root',
password='krishan@64',
database='ambulance_booking'
)
# Function to book an ambulance
def book_ambulance():
name = name_entry.get()
contact = contact_entry.get()
address = address_entry.get()
ambulance_type = ambulance_type_var.get()
if not name or not contact or not address or not
ambulance_type:
[Link]("Input Error", "All fields are
required!")
return
try:
conn = connect_db()
cursor = [Link]()
[Link](
"INSERT INTO bookings (name, contact, address,
ambulance_type) VALUES (%s, %s, %s, %s)",
(name, contact, address, ambulance_type)
)
[Link]()
[Link]()
[Link]("Success", "Ambulance booked
successfully!")
name_entry.delete(0, [Link])
contact_entry.delete(0, [Link])
address_entry.delete(0, [Link])
except [Link] as err:
[Link]("Database Error", f"Error:
{err}")
# Create the UI
root = [Link]()
[Link]("Ambulance Booking System")
# Labels and Entries
[Link](root, text="Name").grid(row=0, column=0,
padx=10, pady=5)
name_entry = [Link](root)
name_entry.grid(row=0, column=1, padx=10, pady=5)
[Link](root, text="Contact").grid(row=1, column=0,
padx=10, pady=5)
contact_entry = [Link](root)
contact_entry.grid(row=1, column=1, padx=10, pady=5)
[Link](root, text="Address").grid(row=2, column=0,
padx=10, pady=5)
address_entry = [Link](root)
address_entry.grid(row=2, column=1, padx=10, pady=5)
# Ambulance Type Dropdown
[Link](root, text="Ambulance Type").grid(row=3,
column=0, padx=10, pady=5)
ambulance_type_var = [Link](root)
ambulance_type_var.set("Select Type")
ambulance_type_menu = [Link](root,
ambulance_type_var, "Basic", "Advanced", "ICU",
"Neonatal")
ambulance_type_menu.grid(row=3, column=1, padx=10,
pady=5)
# Book Button
book_button = [Link](root, text="Book Ambulance",
command=book_ambulance)
book_button.grid(row=4, columnspan=2, pady=20)
# Start the main loop
[Link]()
Output
Testing
1. MySQL (Just after Creation):
2. User name Entry:
3. Booking Confirmation:
4. Booking Table:
Maintenance
Database Maintenance:
• Backup Regularly
• Clean Old Data
• Optimize Tables:
Code Maintenance:
• Use Version Control
• Update Libraries
• Handle Errors
Security:
• Hash Passwords
• Limit Database Access
• Input Validation
Bug Fixes and Updates:
• Fix Bugs Quickly
• Test New Features
Bibliography
1. For Context:
[Link]
2. For Tkinter:
[Link]