0% found this document useful (0 votes)
18 views26 pages

Project Raghav

Uploaded by

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

Project Raghav

Uploaded by

priyanshu18204
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 26

Signature: Submitted by:

Raghav
Bachheti
12th – B
This is to certify that Raghav Bachheti of Class XII has
successfully completed the Computer Science project
titled Computer Sales And Services System under
the guidance of Ms. Sucheta Mam for the academic
year 2024-25.
The project represents the student’s own work and
reflects their dedication and thorough research on the
subject. The student has met all the requirements and
deadlines, making this project eligible for evaluation by
the school.

Date:
Teacher’s Signature
 Acknowledgement
 What is MySQL-Python Connectivity?
 Project Review
 Project Code
 Queries
 Database
 Bibliography
I would like to express my sincere gratitude to all
those who contributed to the successful completion of
this
project.
Firstly, I would like to thank my teacher Ms.
Sucheta Mam for her valuable guidance, support,
and
encouragement throughout the course of this project.
Her expertise helped shape this work and provided
me with a clear direction.
I also extend my gratitude to the Principal Mam
whose resources and infrastructure were crucial to the
development and completion of this project
A special mention goes to my project partner Piyush,
who offered both moral support and intellectual
input at various stages of the project.
Lastly, I would like to thank my family, for their
unwavering support, patience, and
encouragement.
This project would not have been possible without
the contributions and support of all these individuals.
Thank you!
Python-MySQL connectivity allows Python applications
to interact with MySQL databases, enabling
developers to perform database operations such as
querying,
inserting, updating, and deleting data. This is
achieved using a MySQL connector library, such as
mysql-
connector-python, which provides an interface
between Python and the MySQL.
To establish a connection, you need to install the
MySQL connector using: pip install mysql-connector-
python. After that, you can connect to the MySQL
server by providing necessary credentials.
Once connected, you can use cursor objects to
execute SQL queries and fetch results. Python-MySQL
connectivity is widely used in web development, data
analysis, and business applications, making it
essential for building database-driven applications.
This project is a computer science application that
manages customer, sales, service, and rating
records for a business named "Rocket Computers."
It uses
MySQL to store and retrieve data, allowing users to
add and view customer details, sales transactions,
service requests, service issues, and customer
feedback. The
project aims to streamline business operations
by efficiently managing key data points.

The above project is made on a single database


‘Rocket_Computers’ containing 6 tables as:
Customers, Sales, Sales_Problem, Services,
Service_Problem and Ratings. More details are given
below.

# Import Module
import mysql.connector as sql
from mysql.connector import Error
# Set-Up Connection
try:
con = sql.connect(host="localhost", user="root",
password="mysql123")
if con.is_connected():
print("Successfully
connected.") cur = con.cursor()
except Error as e:
print("Error:",e)
exit()

# Create Database
cur.execute('Create database if not exists
Rocket_Computers;')
cur.execute('use Rocket_Computers')
con.commit()

# Create Tables
def create_tables():
# Create Table Customers
cur.execute('''Create table if not exists Customers (
Phone varchar(15) primary key,
Name varchar(30),
EMail varchar(50) not null,
Address varchar(50) not null);''')

# Create Table Sales


cur.execute('''Create table if not exists Sales
( Sale_ID int primary key not null,
Customer_Phone varchar(15) not null,
Product_Name varchar(30) not null,
Sale_Date date not null,
Amount int not null,
Foreign Key(Customer_Phone) References
Customers(Phone));''')

# Create Table Sales_Problem


cur.execute('''Create table if not exists Sales_Problem
( Problem_ID int primary key,
Sale_ID int not null,
Description varchar(100) not null,
Report_Date date not null,
Foreign Key(Sale_ID) References Sales(Sale_ID));''')
# Create Table Services
cur.execute('''Create table if not exists Services
( Service_ID int primary key,
Customer_Phone varchar(15) not null,
Service_Type varchar(30) not null,
Service_Date date not null,
Service_Cost int not null,
Foreign Key(Customer_Phone) References
Customers(Phone));''')

# Create Table Service_Problem


cur.execute('''Create table if not exists Service_Problem
( Service_Problem_ID int primary key,
Service_ID int not null,
Description varchar(100) not null,
Report_Date date not null,
Foreign Key(Service_ID) References
Services(Service_ID));''')

# Create Table Ratings


cur.execute('''Create table if not exists Ratings
( Rating_ID int primary key,
Customer_Phone varchar(15) not null,
Service_Rating int not null,
Product_Rating int not null,
Feedback varchar(100),
Rating_Date date not null,
Foreign Key(Customer_Phone) References
Customers(Phone));''')

# Save Tables
con.commit()

# Add Customer Details


def add_customer():
p = input("Enter customer phone number:")
n = input("Enter customer name:")
e = input("Enter customer email:")
a = input("Enter customer address:")
cur.execute('''Insert into
Customers(Phone,Name,EMail,Address)
values (%s,%s,%s,%s);''', (p, n, e, a))
con.commit()
print("Customer added successfully!")
# Add Sale Details
def add_sale():
s_id = int(input("Enter sale ID:"))
c_p = input("Enter customer phone number:")
p_n = input("Enter product name:")
s_d = input("Enter sale date (YYYY-MM-DD):")
a = float(input("Enter sale amount:"))
cur.execute('''Insert into Sales
(Sale_ID, Customer_Phone, Product_Name, Sale_Date,
Amount)
values (%s,%s,%s,%s,%s);''',
(s_id, c_p, p_n, s_d, a))
con.commit()
print("Sale added successfully!")

# Add Sale Problem


def add_sale_problem():
sp_id = int(input("Enter sale problem ID:"))
s_id = int(input("Enter sale ID:"))
p_d = input("Enter problem description:")
r_d = input("Enter report date (YYYY-MM-DD):")
cur.execute('''Insert into Sales_Problem
(Problem_ID, Sale_ID, Description, Report_Date)
values (%s,%s,%s,%s);''', (sp_id, s_id, p_d, r_d))
con.commit()
print("Sale problem added successfully!")

# Add Service Details


def add_service():
s_id = int(input("Enter service ID:"))
c_p = input("Enter customer phone number:")
s_t = input("Enter service type:")
s_d = input("Enter service date (YYYY-MM-DD):")
s_c = float(input("Enter service cost:"))
cur.execute('''Insert into Services
(Service_ID, Customer_Phone, Service_Type, Service_Date,
Service_Cost)
values (%s,%s,%s,%s,%s);''', (s_id, c_p, s_t, s_d, s_c))
con.commit()
print("Service added successfully!")

# Add Service Problem


def add_service_problem():
sp_id = int(input("Enter service problem ID:"))
s_id = int(input("Enter service ID:"))
p_d = input("Enter problem description:")
r_d = input("Enter report date (YYYY-MM-DD):")
cur.execute('''Insert into Service_Problem
(Service_Problem_ID, Service_ID, Description,
Report_Date)
values (%s,%s,%s,%s);''', (sp_id, s_id, p_d, r_d))
con.commit()
print("Service problem added successfully!")

# Add Ratings
def add_rating():
r_id = int(input('Enter rating ID:'))
c_p = input("Enter customer phone number:")
s_r = int(input("Enter service rating (1-5):"))
p_r = int(input("Enter product rating (1-5):"))
f = input("Enter feedback (optional):")
r_d = input("Enter rating date (YYYY-MM-DD):")
cur.execute('''Insert into Ratings
(Rating_ID, Customer_Phone, Service_Rating,
Product_Rating, Feedback, Rating_Date)
values (%s,%s,%s,%s,%s,%s);''', (r_id, c_p, s_r, p_r, f, r_d))
con.commit()
print("Rating added successfully!")

# View Sales Records


def view_sales():
cur.execute('Select * from Sales;')
data = cur.fetchall()
for i in data:
print(i)

# View Service Records


def view_services():
cur.execute('Select * from Services;')
data = cur.fetchall()
for i in data:
print(i)

# Main Menu
def main_menu():
while True:
print("Welcome to Rocket Computer Sales and Services")
print("1. Add Customer")
print("2. Add Sale")
print("3. Add Sale Problem")
print("4. Add Service")
print("5. Add Service Problem")
print("6. Add Rating")
print("7. View Sales Records")
print("8. View Service
Records") print("9. Exit")
ch = input("Enter your choice: ")
if ch == '1':
add_customer()
elif ch == '2':
add_sale()
elif ch == '3':
add_sale_problem()
elif ch == '4':
add_service()
elif ch == '5':
add_service_problem()
elif ch == '6':
add_rating()
elif ch == '7':
view_sales()
elif ch == '8':
view_services()
elif ch == '9':
break
else:
print("Invalid choice. Please try again.")

# Run the application


create_tables()
main_menu()

# Close the cursor and connection


cur.close()
con.close()
 Adding Customers:
 Adding Sales
 Adding Sales Problem:

 Adding Services:
 Adding Service Problem:
 Adding Ratings
 View Sales Records:

 View Services Records:


www.google.com
www.wikipedia.org
www.vectorstock.com
www.geeksforgeeks.org

You might also like