Kavin
Kavin
import mysql.connector as m
conn = m.connect(host="localhost", user="root", password="Password")
cur = conn.cursor()
cur.execute("create database if not exists cab;")
conn.close()
def tousedatabase():
import mysql.connector as m
conn = m.connect(host="localhost", user="root", password="Password",
database="cab")
cur = conn.cursor()
cur.execute("use cab")
conn.close()
def empdetails():
import mysql.connector as m
conn = m.connect(host="localhost", user="root", passwd="Password",
database="supermarket")
cur = conn.cursor()
cur.execute("create table if not exists customer (c_no int,customer_name
varchar(30),booking_date date,phone_no int,gender char(1));")
conn.close()
def insertdetails():
import mysql.connector as m
conn = m.connect(host="localhost", user="root", password="Password",
database="cab")
cur = conn.cursor()
c = "y"
while c == "y" or c == "Y":
c_no = int(input("Enter the customer no :"))
c_name = input("Enter customer name")
booking_date = input("Enter booking date :")
c_phone_no =int(input("Enter the phone no :"))
gend = input("Enter the gender:")
q = "insert into
customer(customer_no,customer_name,booking_date,phone_no,gender)values({},'{}','{}'
,'{}','{}')".format(c_no,c_name,booking_date,c_phone_no,gend)
cur.execute(q)
conn.commit()
c = input("Do you want to continue........ (y/n)")
conn.close()
def toshowcustomer():
import mysql.connector as m
conn = m.connect(host="localhost", user="root", password="Password",
database="cab")
cur = conn.cursor()
cur.execute("select * from customer;")
print("customer no | customer name | booking_date | phone_no |
gender | ")
x = cur.fetchall()
for i in x:
print(i)
conn.close()
def updatecustomer():
import mysql.connector as m
conn = m.connect(host="localhost", user="root", password="Password",
database="cab")
cur = conn.cursor()
cab = input("Enter the new name :")
q = "update customer set firstname='{}' where c_no=56;".format(cab)
cur.execute(q)
conn.commit()
conn.close()
def deletecustomomer():
import mysql.connector as m
conn = m.connect(host = "localhost", user = "root", password ="Password",
database = "Pathwalla")
cur = conn.cursor()
g = "DELET FROM student WHERE c_no = 26"
cur.execute(g)
conn.commit()
conn.close()
def main():
c = "y"
while c == "y" or c == "Y":
print("************************************online cab booking Management
System****************************************************************")
print()
print()
print(" Welcome you all")
print()
print()
print()
print()
print("1.To view customer details")
print()
print("2. To input the customer details in the table")
print()
print("3. To update the firstname")
print()
print("4. To Exit")
print()
x = int(input("Enter your choice:"))
if x == 1:
toshowcustomer()
elif x == 2:
insertdetails()
elif x == 3:
updatecustomer()
elif x == 4:
break
main()