Jai Sharma
Jai Sharma
connector as m
c=m.connect(host="localhost",user="root",passwd="cshp",database="jaicarrent")
cu=c.cursor()
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:")
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: ")
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")
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