CSC Activity
CSC Activity
ON
SUBMITTED BY
Name:
Roll Number:
Class: XII-S3
Session: 2024-2025
BONAFIDE CERTIFICATE
SUBJECT:
REGISTER NO:
DATE:
Apart from the effort of me, the success of any project depends largely on
the encouragement and guidelines of many others. I take this opportunity to
express my gratitude to the people who have been instrumental in successful
completion of this project.
Lastly, I would like to thank all my friends and classmates for their help,
suggestions, and cooperation. Their collective enthusiasm and advice were
crucial in completing this project.
Index
1 Python Introduction 1
2 SQL Introduction 4
4 Hardware/Software 7
Requirements
6 Source Code 10
7 Sample Output 33
8 References and 43
Bibliography
PYTHON INTRODUCTION
1
1.3 Installing Python:
It can be installed by using website:
https://www.python.org/downloads/
2
● Using IDLE
3
SQL INTRODUCTION
4
2.3 Installing MySQL:
Step 1: In Google search bar type Mysql download
Step 2: scroll down and click GPL link https://dev.mysql.com/downloads/
Step 3: select MySQL installer for windows
Step 4: Download MSI installer of 296MB file
Step 5: Once the file is downloaded go to your Downloads folder and start your
installation process
Step 6: Start the installation
Step 7: set the password as ‘root’
Step 8: click finish and don’t change the default settings
Step 9: close the MYSQL JS terminal
Step 10: Go to start - all programs – Mysql - MySQL 8.0 command line client
Step 11: enter the password (root) and press enter
5
PYTHON SQL CONNECTIVITY
6
HARDWARE /SOFTWARE REQUIREMENTS
7
PRECISION CAR ZONE
This platform is designed to make car maintenance and repair work easy
and stress-free. This enables you to book an appointment for a car to
repair or make any services online.
It adds and views customer details, including name, phone number,
email, and address.
Maintain a database of vehicles associated with customers, including
details like model, year, and license plate.
It records and views vehicle service details, including service type, cost,
and service date.
This system ensures efficient management of all service-related activities,
making it easier for car service businesses to keep track of their
operations and provide better customer service.
This would also generate the invoice of the repaired or serviced details
according to the service and repair works done.
The project not only focuses on storing and managing data but also
ensures data integrity and user-friendly interaction through a
command- line interface.
Fig. 5.1
8
5.1 Benefits of booking a car service appointment through online:
9
Source Code
import mysql.connector
import datetime
con = mysql.connector.connect(host='localhost',user='root',password='root')
cursor=con.cursor()
def start():
cursor.execute("CREATE DATABASE IF NOT EXISTS car_service")
cursor.execute("USE car_service")
cursor.execute("""
10
service_name VARCHAR(50) NOT NULL,
price INT NOT NULL
);
""")
cursor.execute("""
CREATE TABLE IF NOT EXISTS tasks(
11
feedback_text TEXT,
rating INT,
FOREIGN KEY (booking_id) REFERENCES booking(booking_id),
FOREIGN KEY (user_id) REFERENCES users(user_id)
);
""")
cursor.execute("""
CREATE TABLE IF NOT EXISTS payments(
12
VALUES
(1, 'admin_user', 'admin_pass', 1),
cursor.execute("""
INSERT INTO services (service_id, service_name, price)
VALUES
(1, 'Oil Change', 50),
cursor.execute("""
INSERT INTO booking (booking_id, user_id, service_id, date, status)
13
VALUES
(1, 4, 1, '2025-01-01', 'Completed'),
cursor.execute("""
INSERT INTO feedback (feedback_id, booking_id, user_id, feedback_text, rating)
VALUES
(1, 1, 4, 'Great service!', 5),
con.commit()
start()
#for admin
14
def add_user():
username=input("Enter username:")
password=input("Enter password:")
role_id=input("Enter role ID (1 for Admin, 2 for Tech, 3 for User): ")
con.commit()
def view_users():
cursor.execute("SELECT*FROM users")
users = cursor.fetchall()
print("user_id username role_id")
for user in users:
15
print(user[0], ' ',user[1], ' ', '\t',user[3])
def add_services():
service_name=input("Enter service name:
") price = int(input("Enter service price: "))
def view_services():
cursor.execute("SELECT*FROM services")
services = cursor.fetchall()
def view_user_bookings():
user_id = input("Enter the User ID to view their bookings: ")
cursor.execute("""
SELECT booking.booking_id, services.service_name, booking.date, booking.status
FROM booking
JOIN services ON booking.service_id = services.service_id
WHERE booking.user_id = %s
16
""", (user_id,))
bookings = cursor.fetchall()
if not bookings:
print(f"No bookings found for User ID
{user_id}.") return
print("\nUser's Bookings:")
print("Booking ID\tService Name\tDate\t\
tStatus") for booking in bookings:
print(f"{booking[0]}\t{booking[1]}\t{booking[2]}\t{booking[3]}")
def assign_task():
task_name=input("Enter task name: ")
assigned_to=input("Enter technician user ID: ")
status = 'pending'
17
print("Task assigned succesfully")
def view_feedback():
cursor.execute("""
SELECT feedback.feedback_id, users.username, services.service_name,
feedback.rating, feedback.feedback_text
FROM feedback
JOIN booking ON feedback.booking_id = booking.booking_id
JOIN services ON booking.service_id = services.service_id
JOIN users ON feedback.user_id = users.user_id
""")
feedbacks = cursor.fetchall()
if not feedbacks:
print("No feedback available.")
return
print("\nFeedback Summary:")
print("Feedback ID\tUser\tService Name\tRating\tFeedback")
for feedback in feedbacks:
print(f"{feedback[0]}\t{feedback[1]}\t{feedback[2]}\t{feedback[3]}\t{feedback[4]}")
def view_payments():
cursor.execute("""
SELECT payments.payment_id, users.username, services.service_name,
payments.amount_paid, payments.payment_date, payments.payment_status
FROM payments
JOIN booking ON payments.booking_id = booking.booking_id
JOIN services ON booking.service_id = services.service_id
18
JOIN users ON payments.user_id = users.user_id
""")
payments = cursor.fetchall()
if not payments:
print("No payments found.")
return
print("\nPayments Summary:")
print("Payment ID\tUser\tService Name\tAmount Paid\tDate\t\tStatus")
for payment in payments:
print(f"{payment[0]}\t{payment[1]}\t{payment[2]}\t{payment[3]}\t{payment[4]}\t{payment
[5]}")
def admin_menu():
while True:
print("\nADMIN MENU")
print("1. Add User")
print("2. View Users")
print("3. Add Service")
print("4. View Services")
print("5. View bookings")
print("6. Assign Task")
print("7. View feedback.")
print("8. View payment")
print("9. Exit")
19
add_user()
elif choice == '2':
view_users()
elif choice ==
'3':
add_services()
elif choice == '4':
view_services()
elif choice == '5':
view_user_bookings()
elif choice == '6':
assign_task()
elif choice == '7':
view_feedback()
elif choice == '8':
view_payments()
elif choice == '9':
break
else:
print("Invalid choice. Please try again.")
if status_filter:
cursor.execute('''SELECT task_id, task_name, status FROM tasks WHERE
assigned_to=%s AND status=%s''', (user_id, status_filter))
else:
20
cursor.execute('''SELECT task_id, task_name, status FROM tasks WHERE assigned_to=
%s''', (user_id,))
tasks = cursor.fetchall()
if tasks:
print("\nAssigned tasks:")
print("Task ID\tTask Name\tStatus")
for task in tasks:
print(f"{task[0]}\t{task[1]}\t{task[2]}")
else:
def view_task_details(task_id):
cursor.execute('''SELECT task_name, status, assigned_to FROM tasks WHERE task_id=
%s''', (task_id,))
task = cursor.fetchone()
if task:
print("\nTask Details:")
print(f"Task Name: {task[0]}")
print(f"Status: {task[1]}")
cursor.execute('''SELECT username FROM users WHERE user_id=%s''', (task[2],))
user = cursor.fetchone()
print(f"Assigned To: {user[0]}")
else:
print("Task not found.")
def update_task_status(user_id):
print("\nUpdate Task Status")
21
task_id = input("Enter task ID to update: ")
if task:
if task[1] == 'completed':
print("Task is already completed. Status cannot be updated.")
return
def tech_menu(user_id):
while True:
print("\nTECHNICIAN MENU")
print("1. View Assigned Tasks")
22
print("2. View Task Details")
print("3. Update Task Status")
print("4. Exit")
#for user
def book_service(user_id):
view_services()
service_id=input("Enter the service ID: ")
23
cursor.execute('insert into booking values(%s,%s,%s,%s,%s)',
(next_id,user_id,service_id,date,'pending'))
con.commit()
def view_service_history(user_id):
cursor.execute('select
booking.booking_id,services.service_name,booking.date,booking.status from
booking,services where booking.service_id=services.service_id and booking.user_id=%s',
(user_id,))
history = cursor.fetchall()
if history:
print("\nYour service history.")
def cancel_booking(user_id):
booking_id = input("Enter the Booking ID you want to cancel: ")
con.commit()
24
print('Booking canceled succesfully.')
else:
print("Cannot cancel a completed booking.")
else:
def leave_feedback(user_id):
cursor.execute("""
SELECT booking.booking_id, services.service_name, booking.date, booking.status
FROM booking
JOIN services ON booking.service_id = services.service_id
WHERE booking.user_id = %s
""", (user_id,))
bookings = cursor.fetchall()
if not bookings:
print("No bookings found to leave feedback.")
return
print("\nYour Bookings:")
print("Booking ID\tService Name\tDate\t\
tStatus") for booking in bookings:
print(f"{booking[0]}\t{booking[1]}\t{booking[2]}\t{booking[3]}")
cursor.execute("""
SELECT booking_id FROM booking
WHERE booking_id = %s AND user_id = %s
25
""", (booking_id, user_id))
if not cursor.fetchone():
print("Invalid booking ID.")
return
cursor.execute("""
cursor.execute("""
def make_payment(user_id):
cursor.execute("""
26
FROM booking
JOIN services ON booking.service_id = services.service_id
WHERE booking.user_id = %s AND booking.status = 'pending'
""", (user_id,))
bookings = cursor.fetchall()
if not bookings:
print("No pending bookings available for payment.")
return
cursor.execute("""
SELECT booking_id, service_id FROM booking
WHERE booking_id = %s AND user_id = %s AND status = 'pending'
""", (booking_id, user_id))
booking = cursor.fetchone()
if not booking:
service_id = booking[1]
27
price = cursor.fetchone()[0]
payment_status = 'paid'
payment_date =
datetime.date.today()
cursor.execute("""
def user_menu(user_id):
while True:
print("\nUSER MENU")
print("1. View Available Services")
print("2. Book a Service")
print("3. View Service History")
print("4. Leave feedback")
print("5. Cancel a Booking")
print("6. Make payment")
print("7. Exit")
28
view_services()
elif choice == '2':
book_service(user_id)
elif choice == '3':
view_service_history(user_id)
elif choice == '4':
leave_feedback(user_id)
elif choice == '5':
cancel_booking(user_id)
elif choice == '6':
make_payment(user_id)
elif choice == '7':
break
else:
print("Invalid choice. Try again.")
def login():
username=input("Enter username:")
password=input("Enter password:")
if result:
stored_password=result[1]
user_id=result[0]
role_id=result[2]
29
if password == stored_password:
print('Login successful.')
if role_result:
role_name=role_result[0]
if role_name=="admin":
print("Welcome Admin.")
admin_menu()
elif role_name=="tech":
print('Welcome
tech.')
tech_menu(user_id)
elif role_name=='user':
print('Welcome user.')
user_menu(user_id)
else:
print("Role not found.")
else:
print("Invalid password.")
else:
def sign_up():
30
username=input("Enter username:")
password=input("Enter password:")
role_id=input("Enter role id(1.admin,2.tech,3.user): ")
print("Sign up succesful.")
31
print("Invalid option.")
def main():
while True:
print("WELCOME TO CAR SERVICE MANAGMMENT")
print("1. Login")
print("2. Sign up")
print("3. Exit")
main()
32
Sample Outputs
Python Outputs:
33
34
35
36
37
38
39
MySQL Outputs:
40
41
42
REFERENCES
https://www.python.org/
https://www.w3schools.com/sql/sql_intro.asp
https://www.geeksforgeeks.org/how-to-connect-python-with-sql-
database/
BIBILIOGRAPHY
43