0% found this document useful (0 votes)
12 views2 pages

Jai Sharma

document

Uploaded by

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

Jai Sharma

document

Uploaded by

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

import mysql.

connector as m
c=m.connect(host="localhost",user="root",passwd="cshp",database="jaicarrent")
cu=c.cursor()

print("############### WELCOME TO JAI's CAR RENT SERVICE


##############")

def show_all_cars():
query = ("SELECT * FROM cars")
cu.execute(query)
j=cu.fetchall()
for i in j:
print(i)

def show_available_cars():
query = "SELECT * FROM cars WHERE status = 'available';"
cu.execute(query)
q=cu.fetchone()
print(q)

def show_rented_cars():
query = "SELECT * FROM cars WHERE status = 'rented'"
cu.execute(query)
q=cu.fetchone()
print(q)

def rent_car():
print("1. Show all available cars")
print("2. Any specific car you want to rent")
choice = int(input("Enter your choice: "))

if choice == 1:
show_available_cars()
elif choice == 2:
car_name = input("Enter the car name you want to rent: ")
query = "SELECT * FROM cars WHERE car_name ='{}'".format(car_name)
cu.execute(query)
q=cu.fetchone()
print(q)

pp= input("Enter the ccode of the car you want to rent: ")
oo= input("Enter your name: ")
ii= input("Date to rent the car (YYYY-MM-DD): ")
uu= input("Date to return the car (YYYY-MM-DD): ")
gg=input("enter adhaar no:")

insert_user_query = "INSERT INTO user (ccode, name, date_to_rent,


date_to_return,adhaarno)VALUES ('{}','{}','{}','{}','{}')".format(pp,oo,ii,uu,gg)
update= "UPDATE cars SET status = 'rented' WHERE ccode ='{}'".format(pp)

cu.execute(insert_user_query)
cu.execute(update)
c.commit()
c.commit()
print("##### YOU HAVE SUCCESSFULLY RENTED A CAR ######")

def list_car_for_rent():
print("--------- CAR DETAILS ----------")
ccode = input("Enter ccode: ")
name = input("Enter car model name: ")
carno = input("Enter car number: ")
colour = input("Enter car's colour: ")
fuel_type = input("Enter fuel type: ")

print("--------- CLIENT DETAILS -----------")


client_name = input("Enter your name: ")
ownership = input("Ownership (Y/N): ")
time_under = input("Time under ownership (in years): ")
aa=input("enter adhaar no:")

insert_car_query = "INSERT INTO cars (ccode,car_name, carno, colour,


fuel_type)VALUES('{}','{}','{}','{}','{}')".format(ccode,name,carno,colour,fuel_typ
e)
insert_user_query = "INSERT INTO user (ccode, name, ownership,
time_under_ownership,adhaarno)VALUES
('{}','{}','{}','{}','{}')".format(ccode,client_name,ownership,time_under,aa)
cu.execute(insert_car_query)
cu.execute(insert_user_query)
c.commit()
c.commit()
print("######## YOU SUCCESSFULLY LISTED YOUR CAR FOR RENT
#######")

while True:
print("--------Available Options---------")
print("1. Show All Car Details")
print("2. Show All Available Cars")
print("3. Show All Cars on Rent")
print("4. Rent a Car")
print("5. List a Car for Rent")

choice = int(input("******ENTER YOUR CHOICE*******"))

if choice == 1:
show_all_cars()
elif choice == 2:
show_available_cars()
elif choice == 3:
show_rented_cars()
elif choice == 4:
rent_car()
elif choice == 5:
list_car_for_rent()
else:
print("#### YOU HAVE MADE AN INVALID CHOICE ####")
break

You might also like