Jai
Jai
##############")
import mysql.connector as m
c=m.connect(host="localhost",user="root",passwd="WJ28@krhps",database="jai")
cu=c.cursor
car="create table cars(ccode varchar(3) primary key ,car_name varchar(20),carno.
varchar(15),colour varchar(10),modified(Y or N) varchar(3),replaced_parts
varchar(10),fuel_type varchar(10),status varchar(20) default 'available')"
user="create table user(ccode varchar(3) foreign key, name varchar(30),ownership
varchar(10),time_under_ownership(years) int, date_to_rent date, date_to_return
date)"
cu.execute(car)
cu.execute(user)
c.commit()
def showall():
s="select * from cars"
cu.execute(s)
j=cu.fetchall()
for i in j:
print(i)
def available():
a="select from cars where status='available'"
cu.execute(a)
aa=cu.fetchmany()
print(aa)
def on_rent():
r="select from cars where status='rented'"
cu.execute(r)
rr=cu.fetchmany()
print(rr)
def to_rent():
print("1. show all available","\n2.any specific you car you want to rent")
choice=int(input("enter your choice:"))
if choice==1:
available()
elif ch==2:
sp=input("enter the car name you want to rent")
bb="select * from cars where car_name='{}'".format(sp)
cu.execute(bb)
b=cu.fetchone()
print(b)
else:
print("INVALID CHOICE")
q=input("enter the ccode of car you want to enter:")
w=input("enter your name:")
e=input("date to rent the car:")
r=input("date to return the car:")
qq="insert into user (ccode, name, date_to_rent, date_to_return)
values('{}','{}','{}','{}')".format(q,w,e,r)
qqq="update cars set status='RENTED' where ccode='{}'".format(q)
cu.execute(qq)
cu.execute(qqq)
c.commit()
def list_a_vehicle():
print("--------- CAR DETAILS ----------")
bheem=input("enter ccode:")
chutki=input("enter you car model name:")
raju=input("enter car's colour:")
jagu=input("Is your car modified?")
dholu=input("no. of replace parts:")
bholu=input("enter fuel type:")
print("--------- CLIENT DETAILS -----------")
indraverma=input("enter your name:")
indumati=input("ownership?")
tuntun=input("time under ownership:")
senapati="insert into cars
values('{}','{}','{}','{}','{}','{}')".format(bheem,chutki,raju,jagu,dholu,bholu)
dhomketu="insert into user (ccode,name,ownership,time_under_ownership)
values('{}','{}','{}','{}')".format(bheem,indraverma,indumati,tuntun)
cu.execute(senapati)
cu.execute(dhomketu)
c.commit()
c='y'
while c=='y':
print("--------Available Options---------","\n1. Show All Car Details","\n2. Show
All Available cars","\n3. Show All Cars on Rent","\n4. To Rent a Car","\n5. To List
a Car To Rent")
kaddu=int(input("******ENTER YOUR CHOICE*******"))
if kaddu==1:
showall()
elif kaddu==2:
available()
elif kaddu==3:
on_rent()
elif kaddu==4:
to_rent()
elif ch==5:
list_a_vehicle()
else:
print("#### YOU HAVE MADE AN INVALID CHOICE ####")
continue