0% found this document useful (0 votes)
43 views35 pages

Python MySQL Parking Management System

Uploaded by

priyanshukymar7
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views35 pages

Python MySQL Parking Management System

Uploaded by

priyanshukymar7
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Name - Daksh Bhatt

Chetan Kashyap
Mayank Lakchaura

PROJECT ON:-
“Parking Management System”
CERTIFICATE

This is to certify that the students Daksh Bhatt,


Chetan Kashyap and Mayank Lakchaura have
successfully completed their Computer Science
project entitled “PYTHON – MYSQL
CONNECTIVITY PROJECT ON PARKING
MANAGEMENT”.
The project was carried out as part of their
coursework during the academic session [2025
2026].
The group has demonstrated the ability to use
Python programming along with MySQL
database connectivity for building a simple and
effective Parking Management System. Their
teamwork, effort, and practical application of
concepts are highly appreciated.

Signature: ______________
ACKNOWLEDGEMENT

We would like to express our heartfelt gratitude to


our Computer Science teacher Mrs Amrita Das for
her valuable guidance, constant support, and
encouragement throughout the completion of our
project “Python–MySQL Connectivity Project on
Parking Management.”
We also extend our sincere thanks to our school
principal Mrs Sita Jha for providing us with the
facilities and environment to carry out this project
successfully.
We are grateful to our classmates, friends, and
family members for their cooperation and motivation
during the project work.
Finally, we would like to thank the Almighty for giving
us the strength and determination to complete this
project successfully.

Submitted by:
Daksh, Chetan and Mayank
INDEX
 Objective
 Introduction
 Hardware and software requirements
 Function used
 Advantages
 Disadvantages
 Source code
 Output
 Scope of program
 Bibliography
OBJECTIVE
The objective of this project is to design and implement a
functional Parking Management System using Python and
MySQL. The project aims to demonstrate the concepts of
database connectivity, data handling, and real-world
problem-solving through a simple yet effective application.
The system is developed to manage vehicle parking
activities in an organized and efficient manner by combining
Python‟s programming capabilities with the data storage
and retrieval features of MySQL.

The primary goal is to create a system that can store,


update and manage important parking-related information.
This includes allocating parking slots, recording vehicle
entry time, calculating the total duration of parking, and
generating the final parking charges. By automating these
tasks, the project removes the possibility of human errors,
reduces manual work and ensures smooth operation.

Another important objective is to help students understand


how Python interacts with a database using the MySQL
Connector module. Through this, the project highlights how
backend operations such as insertion, deletion, searching
and fetching of records are performed using SQL queries
inside a Python program. It encourages practical learning of
CRUD operations (Create, Read, Update and Delete) and
strengthens understanding of database management
systems.

The project also aims to show how real-world systems


handle data in a structured way. By assigning unique
parking slots and maintaining proper records of each
vehicle, the system ensures that all data remains organized.
The use of date and time functions helps students
understand how timestamps are stored and processed in
programming.

Overall, the project‟s objective is to develop a simple, user-


friendly program that can manage the daily operations of a
parking facility. It demonstrates logical thinking,
programming skills, database connectivity, and problem-
solving ability. This project serves as a practical example of
how Python and MySQL together can be used to build
meaningful applications that are useful in everyday life.
INTRODUCTION
Parking management is an essential part of modern urban life, as
increasing numbers of vehicles require organized and efficient
parking systems. Manual methods of recording vehicle entry, exit
and calculating charges often lead to mistakes, confusion and time
delays. To overcome these issues, computerized solutions are used
to automate parking operations, improve accuracy and save effort.
This project, Parking Management System using Python and MySQL,
is designed to model how such a system works in a simple and
practical way.

The project integrates Python, a powerful and easy-to-understand


programming language, with MySQL, a widely used database
management system. Python handles the user interface, logic and
menu-driven operations, while MySQL stores all the parking-related
data securely. With the help of the MySQL connector, Python
interacts directly with the database, allowing smooth insertion,
searching, deletion and updating of records. This demonstrates how
real-world applications use backend databases to maintain large
amounts of information properly.

The system developed in this project is capable of managing tasks


such as allocating parking slots, registering incoming vehicles,
maintaining owner details, calculating parking time, generating
charges and removing vehicles after exit. It also supports helpful
features like checking slot availability and exporting data for backup.

This project helps students understand the importance of database


connectivity, structured data storage, and automation in day-to-day
operations. By combining programming with database handling, the
Parking Management System becomes a practical example of how
technology simplifies management tasks and increases overall
efficiency.
HARDWARE AND
SOFTWARE REQUIREMENTS
To successfully run the project “Python–MySQL
Connectivity Project on Parking Management”, the following
hardware and software resources are required:

 Hardware Requirements
- Processor: Intel i3 / AMD Ryzen 3 or above
- RAM: Minimum 4 GB ( 8 GB recommended )
- Hard Disk: At least 500 MB free space for project and
database
- Display: Standard monitor with 1024 x 768 resolution
or higher
- Keyboard & Mouse : For input operations
 Software Requirements
- Operating System: Windows 10/11,Linux or MacOS
- Programming Language: Python 3.x (preferably 3.8 or
above )
- Database: MySQL Server (version 5.7 or above)
- Connector/Driver: MySQL Connector for Python
(mysql-connector-python or pymysql library)
- IDE/Editor: Pycharm/ VS Code / IDLE
- Additional tools (optional): MySQL workbench for
database management
FUNCTIONS USED
In the project “Python–MySQL Connectivity Project on
Parking Management”, several functions are used to
perform different operations on the parkingdb database.
These functions make the program modular, easy to
understand, and reusable.
List of Functions:-
1. connectDB()
Connects Python to the MySQL database using the provided credentials
and returns the connection object.
2. createTables()
Creates the parking table in the database if it doesn‟t already exist,
ensuring the project can store vehicle data.
3. parkVehicle()
Adds a new vehicle entry into the parking system, assigning the first
available slot and storing entry time.
4. exitVehicle()
Records the exit time of a vehicle, calculates parking fees based on
duration, and deletes the record from active slots.
5. searchVehicle()
Searches for a vehicle in the database by its number and displays its
details, such as slot, owner, and entry time.
6. displayAll()
Shows all currently parked vehicles and recently exited vehicles with their
details for easy monitoring.
7. slotStatus()
Displays the total number of parking slots, how many are used, and how
many are free at the current time.
8. exportCSV()
Exports all parking data to a CSV file for backup or reporting purposes.
9. menu()
The main interactive loop that displays options 1–7, calls respective
functions based on user input, and keeps the program running.
ADVANTAGES
The project “Python-MySQL Connectivity Project on
Parking Management‟‟ provides several benefits over
traditional manual systems. Some of the major
advantages are:

1. Simple and User-Friendly


The system provides a clear menu-driven interface where
users can select options by typing numbers. This
simplicity ensures that even someone with minimal
computer knowledge can operate it. There is no complex
installation beyond Python and MySQL, and all functions
have prompts and messages that guide the user step by
step.
2. Persistent Storage with MySQL
Vehicle data, including entry and exit times, owner
names, and charges, are stored in a MySQL database.
This means the information is safe even if the program is
closed or the computer is restarted. Unlike storing data in
temporary memory (like Python lists), this allows the
system to maintain accurate historical records for
reporting and auditing purposes.
3. Prevents Duplicate Entries
The system checks whether a vehicle is already parked
before allowing a new entry. This reduces errors,
prevents slot conflicts, and ensures that the parking
management records reflect the actual situation in the
parking area.
4. Automatic Fee Calculation
When a vehicle exits, the system automatically calculates
the parking fee based on the duration of stay. This avoids
manual calculations, reduces human error, and saves
time for attendants, making the process more efficient
and transparent.
5. Slot Management
The system keeps track of occupied and free slots in real
time. Users can quickly see which slots are available,
which prevents double parking and optimizes the
utilization of available space. This feature is essential for
efficient parking lot management, especially in busy
areas.
6. Data Backup and Export
All records can be exported to a CSV file with a single
command. This allows the school or organization to keep
a backup, maintain reports for management, or submit
records as part of documentation. CSV files are easy to
open in Excel or Google Sheets, making the data readable
and shareable.
7. Modular and Extensible
The project is designed with separate functions for each
task, such as adding a vehicle, exiting a vehicle, or
checking slot availability. This modular design makes the
code easy to understand, debug, and extend. Future
enhancements like adding a GUI, advanced billing rules,
or online connectivity can be implemented without
rewriting the entire system.
8. Educational Value
This project demonstrates real-life application of
programming concepts, database management, and
problem-solving skills. It helps students understand how
Python can interact with a database, manage data, and
provide a usable software tool. It is an excellent learning
experience for anyone preparing for computer science
projects at the school or beginner level.
DISADVANTAGES
Although the project „Python-mySQL Connectivity
Project on Parking Management” provides several
benefits, it also has a few limitations:

1. No Graphical User Interface (GUI)


The system runs entirely in the command-line interface
(CLI). While functional, it is less visually appealing and
may be harder for some users to navigate compared to
a GUI-based system with buttons, forms, and visual slot
indicators.
2. Requires MySQL Installation and Setup
To run the project, MySQL server must be installed and
configured correctly. Beginners may face challenges
with installation, setting passwords, creating the
database, or connecting Python to MySQL.
3. Limited to Small Scale Usage
This system is designed for school-level projects or
small parking areas. For very large parking lots with
hundreds of vehicles and multiple entry/exit points, the
program may not be efficient and would require
significant upgrades.
4. Manual Data Entry
Vehicle numbers, owner names, and slot assignments
must be entered manually. This increases the risk of
typing errors, such as incorrect vehicle numbers or
duplicated entries if users are not careful.
5. No Advanced Security Features
The program does not include user authentication or
data encryption. Anyone with access to the system can
view, add, or delete records. For real-world
commercial parking systems, security would need to be
significantly enhanced.
6. No Real-Time Slot Updates in Networked Environment
The system works well on a single computer. However,
if multiple attendants or computers try to access the
same database simultaneously, the system may require
additional code for concurrency and real-time
synchronization.
7. No Automatic Alerts or Notifications
Unlike advanced parking management systems, this
project does not notify users of full slots, overstay, or
payment reminders. All monitoring must be done
manually by checking the system.
SOURCE CODE
“Parking Management System with Python and
MySQL connectivity ~ 330 lines”
Features:

 MySQL connection and database/table setup


 Add Vehicle – Register and assign slot.
 Exit & Billing – Calculate fees automatically.
 Search Vehicle – Find by number.
 Display Records – Show all vehicles.
 Slot Status – Check free/occupied slots.
 Export Data – Backup to CSV.
 Menu Driven – Easy CLI navigation.
 Duplicate Check – Prevent same vehicle twice.
 Modular Design – Clean, extendable code.
# -------------------- IMPORT LIBRARIES --------------------
import [Link]
from [Link] import Error
import datetime
import csv
import os

#
==================================================
========
# ------------------- MYSQL CONNECTION --------------------
print("============================================
============")
print(" Welcome to Parking Management System ")
print("============================================
============\n")

# Ask for MySQL username and password


db_user = input("Enter your MySQL username: ")
db_password = input("Enter your MySQL password: ")

try:
connection = [Link](
host="localhost",
user=db_user,
password=db_password,
database="parkingdb"
)

if connection.is_connected():
print("\nSuccessfully connected to MySQL Database!")
cursor = [Link]()
[Link]("SELECT DATABASE();")
db = [Link]()
print(f"Connected to database: {db[0]}")
print("\n")

# ------------------- CREATE TABLE IF NOT EXISTS -------------


-------
create_table_query = """
CREATE TABLE IF NOT EXISTS parking (
slot INT,
vehicle_no VARCHAR(20),
owner_name VARCHAR(50),
owner_phone VARCHAR(15),
entry_time DATETIME,
exit_time DATETIME,
charge INT
);
"""
[Link](create_table_query)
[Link]()
print("Table 'parking' is ready.\n")

except Error as e:
print(f"Error: {e}")
print("Cannot connect to MySQL. Exiting program.")
exit()

#
==================================================
========
# ------------------- PARKING CONFIG ----------------------
TOTAL_SLOTS = 20
print(f"Total parking slots available: {TOTAL_SLOTS}\n")

#
==================================================
========
# ------------------- FUNCTIONS --------------------------

# ------------------- PARK VEHICLE ------------------------


def park_vehicle():
"""
Park a vehicle in the parking lot.
Collects vehicle number, owner name, and owner phone.
Finds first available slot and inserts record into MySQL.
"""
print("\n--- Park Vehicle ---")
vehicle_no = input("Enter vehicle number:
").upper().strip()
if vehicle_no == "":
print("Vehicle number cannot be empty.\n")
return

owner_name = input("Enter owner name: ").strip()


if owner_name == "":
print("Owner name cannot be empty.\n")
return

owner_phone = input("Enter owner phone number:


").strip()
if owner_phone == "":
print("Owner phone number cannot be empty.\n")
return

# Check if vehicle already parked


[Link](
"SELECT * FROM parking WHERE vehicle_no=%s AND
exit_time IS NULL",
(vehicle_no,)
)
if [Link]():
print(f"Vehicle {vehicle_no} is already parked.\n")
return

# Find occupied slots


[Link]("SELECT slot FROM parking WHERE
exit_time IS NULL")
occupied_slots = [row[0] for row in [Link]()]

# Find first free slot


available_slots = [i for i in range(1, TOTAL_SLOTS + 1) if i
not in occupied_slots]
if not available_slots:
print("Parking full! No available slots.\n")
return

slot_no = available_slots[0]
entry_time = [Link]()

# Insert record
[Link](
"INSERT INTO parking (slot, vehicle_no, owner_name,
owner_phone, entry_time) VALUES (%s,%s,%s,%s,%s)",
(slot_no, vehicle_no, owner_name, owner_phone,
entry_time)
)
[Link]()
print(f"Vehicle {vehicle_no} parked in slot {slot_no}.")
print(f"Owner: {owner_name}, Phone: {owner_phone}")
print(f"Entry time recorded: {entry_time}\n")

# ------------------- EXIT VEHICLE ------------------------


def exit_vehicle():
"""
Exit a vehicle from parking.
Updates exit time and calculates charges.
"""
print("\n--- Exit Vehicle ---")
vehicle_no = input("Enter vehicle number to exit:
").upper().strip()
if vehicle_no == "":
print("Vehicle number cannot be empty.\n")
return

[Link](
"SELECT slot, entry_time FROM parking WHERE
vehicle_no=%s AND exit_time IS NULL",
(vehicle_no,)
)
result = [Link]()
if not result:
print(f"Vehicle {vehicle_no} not found in parking.\n")
return

slot_no, entry_time = result


exit_time = [Link]()
duration_hours = (exit_time - entry_time).total_seconds() /
3600
charge = int(duration_hours * 10) + 10 # Minimum 10 units

[Link](
"UPDATE parking SET exit_time=%s, charge=%s
WHERE vehicle_no=%s AND slot=%s",
(exit_time, charge, vehicle_no, slot_no)
)
[Link]()

print(f"Vehicle {vehicle_no} exited from slot {slot_no}.")


print(f"Exit time: {exit_time}")
print(f"Total parking charges: {charge} units\n")

# ------------------- SEARCH VEHICLE ----------------------


def search_vehicle():
"""
Search for vehicle details using vehicle number.
"""
print("\n--- Search Vehicle ---")
vehicle_no = input("Enter vehicle number to search:
").upper().strip()
if vehicle_no == "":
print("Vehicle number cannot be empty.\n")
return

[Link]("SELECT * FROM parking WHERE


vehicle_no=%s", (vehicle_no,))
rows = [Link]()
if rows:
print("Slot | Vehicle No | Owner Name | Owner Phone |
Entry Time | Exit Time | Charge")
for row in rows:
print(row)
print("\n")
else:
print(f"No records found for vehicle {vehicle_no}.\n")

# ------------------- DISPLAY ALL VEHICLES ----------------


def display_all():
"""
Display all vehicles currently in the parking lot.
"""
print("\n--- Display All Vehicles ---")
[Link]("SELECT * FROM parking ORDER BY
slot")
rows = [Link]()
if rows:
print("Slot | Vehicle No | Owner Name | Owner Phone |
Entry Time | Exit Time | Charge")
for row in rows:
print(row)
print("\n")
else:
print("No vehicles currently in the parking lot.\n")

# ------------------- SLOT STATUS ------------------------


def slot_status():
"""
Show occupied and free parking slots.
"""
print("\n--- Parking Slot Status ---")
[Link]("SELECT COUNT(*) FROM parking
WHERE exit_time IS NULL")
occupied = [Link]()[0]
free = TOTAL_SLOTS - occupied
print(f"Total slots: {TOTAL_SLOTS}")
print(f"Occupied slots: {occupied}")
print(f"Free slots: {free}\n")

# ------------------- EXPORT DATA TO CSV -----------------


def export_csv():
"""
Export all parking data to a CSV file.
"""
print("\n--- Export Parking Data to CSV ---")
[Link]("SELECT * FROM parking ORDER BY
slot")
rows = [Link]()
if not rows:
print("No data to export.\n")
return

filename = "parking_data.csv"
with open(filename, 'w', newline='') as f:
writer = [Link](f)
[Link](["Slot", "Vehicle No", "Owner Name",
"Owner Phone", "Entry Time", "Exit Time", "Charge"])
[Link](rows)

print(f"Data exported successfully to


{[Link](filename)}\n")

#
==================================================
========
# ------------------- MAIN MENU ---------------------------
while True:
print("""
--- Parking Management System Menu ---
1. Park Vehicle
2. Exit Vehicle
3. Search Vehicle
4. Display All Vehicles
5. Slot Status
6. Export Data
7. Exit
""")
choice = input("Enter your choice (1-7): ").strip()

if choice == "1":
park_vehicle()
elif choice == "2":
exit_vehicle()
elif choice == "3":
search_vehicle()
elif choice == "4":
display_all()
elif choice == "5":
slot_status()
elif choice == "6":
export_csv()
elif choice == "7":
print("\nExiting program...")
[Link]()
[Link]()
print("MySQL connection closed. Goodbye!")
break
else:
print("Invalid choice! Please enter a number between 1
and 7.\n")
OUTPUT
TABLE:-

RUNNING PROGRAM:-
Final Table :-
SCOPE OF PROGRAM
The Project “Python-MySQL Connectivity Project on
Parking Management” has a wide scope as it
demonstrates the practical use of programming and
database for solving real-world problems.
1. Academic Scope :-

o Helps students learn Python programming and


MySQL database connectivity.
o Teaches CRUD operations: Create, Read, Update,
Delete.
o Demonstrates real-world application of programming
concepts in databases.
o Enhances understanding of functions, loops,
conditional statements, and modules in Python.
o Introduces basic data validation and error handling
techniques.

2. Practical Scope :-

o Can be implemented in small parking lots, schools,


and office buildings.
o Tracks vehicle entry and exit, calculates parking
charges automatically.
o Stores owner details (name, phone) for better
management and accountability.
o Can generate reports or export data to CSV for
analysis.
o Helps reduce manual effort and errors in managing
parking slots.

3. Future Scope :-

o Can be upgraded to a web-based or mobile application


for remote access.
o Integration with IoT devices: sensors to detect free
slots automatically.
o Dynamic pricing models based on peak hours or
subscription plans.
o Automated notifications via SMS/email for vehicle
entry, exit, or low availability.
o Expansion to multi-level parking structures with real-
time slot tracking.
o Integration with payment gateways for digital
payments.
BIBLIOGRAPHY
While preparing the project “Python MySQL
Connectivity Project on Parking Management”, the
following sources of information were referred to :
1. Books & Study Material:-

o Sumita Arora, Computer Science with Python, Class


XII, Dhanpat Rai & Co.
o CBSE Computer Science curriculum guidelines.
o Python and MySQL reference manuals.

2. Web Resources:-
o [Link] – Official Python Documentation
o [Link] – MySQL Documentation
o [Link] – Tutorials and examples
o [Link] – Python & SQL tutorials

3. Practical Guidance:-
o Guidance and support from subject teacher.
o Classroom lectures and practical lab sessions.

You might also like