0% found this document useful (0 votes)
86 views6 pages

Cs Project

This Python code connects to a MySQL database called "shoe_billing" and allows users to enter and view customer details for shoe orders. It prompts the user for login credentials, then displays a menu to either enter new customer data by inserting it into a database table or view existing customer data by querying the table. The data includes fields for the shoe code, brand, customer name, phone number, address, and amount.

Uploaded by

Dron Sharma
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)
86 views6 pages

Cs Project

This Python code connects to a MySQL database called "shoe_billing" and allows users to enter and view customer details for shoe orders. It prompts the user for login credentials, then displays a menu to either enter new customer data by inserting it into a database table or view existing customer data by querying the table. The data includes fields for the shoe code, brand, customer name, phone number, address, and amount.

Uploaded by

Dron Sharma
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/ 6

Source Code

import mysql.connector as sql


conn=sql.connect(host='localhos
t',user='root',passwd='manager'
,database='shoe_billing')
#if conn.is_connected():
#print('connected
sucessfully')
conn.autocommit=True
c1=conn.cursor()
#c1.execute("create table
shoe_details(shoe_code int
primary key,brand_name
varchar(25),customer_name
varchar(25),customer_number,,cu
stomer_address,amount )")
c1=conn.cursor()
user=input("enter user")
passwd=input("enter password")
if user=='raghavan' and
passwd=='leo':
print("
shoe billing")
print("
")
print("1:ENTER CUSTOMER
DETAILS")
print("
")
print("2:SHOW CUSTOMERS
DETAILS")
print("
")
v_choice=int(input("enter
the choice"))
if v_choice==1 :
code=input("enter
code=")
brand =input("enter
brand=")
name=input("enter
customer name=")
number=input("enter
phone number=")
details=input
("adress=")
amount=input("amount=")
c1.execute("insert
into shoe_details values
("+code+",'"+brand+"'"+",'"+nam
e+"',"+number+",'"+details+"',"
+amount+")")
conn.commit()
elif v_choice==2:
v_code=input("enter
the code number")
c1.execute("select
* from shoe_details where
shoe_code ="+v_code)
data=c1.fetchall()
print("Shoe
code:",data[0][0])
print("brand
name:",data[0][1])
print("customer
name:",data[0][2])
print("customer
number:",data[0][3])
print("customer
detail:",data[0][4])
print("amoumt:",data[0][5])
Project Code
import mysql.connector as sql
conn=sql.connect(host='localhost',user='r
oot',passwd='kvs',database='shoe_billing'
)
if conn.is_connected():
print('connected sucessfully')
print('user =
raghavan','password=leo')
conn.autocommit=True
c1=conn.cursor()
c1.execute("create table if not exists
shoe_details(shoe_code int,brand_name
varchar(25),customer_name
varchar(25),customer_number
int,customer_address varchar(20),amount
int)")
c1=conn.cursor()
user=input("enter user: ")
passwd=input("enter password: ")
if user=='raghavan' and passwd=='leo':
print(" shoe
billing")
print("
")
print("1:ENTER CUSTOMER DETAILS")
print("
")
print("2:SHOW CUSTOMERS DETAILS")
print("
")
v_choice=int(input("enter the
choice"))
if v_choice==1:
# for i in range(20):
data=("""INSERT INTO
shoe_details(shoe_code,brand_name,custome
r_name,customer_number,customer_address,a
mount)VALUES (%s,%s,%s,%s,%s,%s)""")
code=input("enter code=")
brand =input("enter
brand=")
name=input("enter
customer name=")
number=int(input("enter
phone number="))
details=input ("adress=")
amount=input("amount=")
r=(code,brand,name,number,details,amount)
c1.execute(data,r)
conn.commit()
print ('Data stored
successfully \n quitting program')
elif v_choice==2:
v_code=input("enter the code
number")
c1.execute("select * from
shoe_details where shoe_code ="+v_code)
data=c1.fetchall()
print("Shoe code:",data[0]
[0])
print("brand name:",data[0]
[1])
print("customer
name:",data[0][2])
print("customer
number:",data[0][3])
print("customer
detail:",data[0][4])
print("amoumt:",data[0][5])
conn.commit()

You might also like