0% found this document useful (0 votes)
32 views3 pages

Smartphone

The document contains code snippets for MySQL commands and Python functions to manage orders in a database. The MySQL code creates an orders table with multiple columns. The Python code contains functions to display, add, remove and generate bills for orders by querying the orders table. It takes customer input to add or remove orders and displays orders and bills in a formatted table.

Uploaded by

Dhruv Tailor
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)
32 views3 pages

Smartphone

The document contains code snippets for MySQL commands and Python functions to manage orders in a database. The MySQL code creates an orders table with multiple columns. The Python code contains functions to display, add, remove and generate bills for orders by querying the orders table. It takes customer input to add or remove orders and displays orders and bills in a formatted table.

Uploaded by

Dhruv Tailor
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/ 3

MYSQL Commands:

Use SMARTPHONES;

Create table order(

 Column name,
 Column name,
 Column name,
 Column name,
 Column name,

PYTHON CODES:

def displayorder():

print('---------------------------------DISPLAY ORDERS--------------------------------')

c=con.cursor()

c.execute('SELECT* FROM Orders')

data=c.fetchall()

df=pd.DataFrame(data,columns=['OrderNO','CName','PName & Qty','Amt','Date'])

print(df)

print('\n','\n')

a=int(input("Press 0 to Exit"))

if a==0:

order()

def addorder():

print('---------------------------------ADD ORDER--------------------------------')

while True:

c=con.cursor()

ci=int(input('Enter Order No.:'))

cn=input('Enter Customer Name:')

md,t,td={},0,''

while True:

mn=input('Enter Product name:')

mq=int(input('Enter Quantity:'))

if mn=='0':

break
else:

md[mn]=mq

td=td+mn+':'+str(mq)+' | '

Q5="SELECT PName,Cost FROM Products"

c.execute(Q5)

d=c.fetchall()

for j in md:

for i in d:

if i[0]==j:

t = t + (i[1]*md[j])

dt=input('Enter Date of order:')

data=(ci,cn,td,t,dt)

Q6="INSERT INTO Orders values(%s,%s,%s,%s,%s)"

c.execute(Q6,data)

con.commit()

print('Data Entered Successfully')

print('_______________________________________________________________________________','\n','1.Add
More','\n','2.Exit','\n','_______________________________________________________________________________')

a=int(input('Enter Your Choice:'))

if a==2:

order()

else:

addorder()

def removeorder():

print('---------------------------------REMOVE ORDER--------------------------------')

while True:

ID=input('Enter Order NO. to delete:')

Q2="DELETE from Orders WHERE OrderNo='"+ID+"'"

c=con.cursor()

c.execute(Q2)

con.commit()
print(c.rowcount,"Record Deleted")

print('_______________________________________________________________________________','\
n','1.Delete More','\n','2.Exit','\
n','_______________________________________________________________________________')

a=int(input('Enter Your Choice:'))

if a==2:

order()

else:

removeorder()

def genbill():

print('---------------------------------GENERATE BILL------------------------------------------')

c=con.cursor()

cn=input('Enter Customer Name to Generate bill:')

print('-------------------------------------------BILL INVOICE------------------------------------')

print('Customer Name:',cn)

Q7="SELECT OrderNo,PNAMEnQAUNTITY,Cost,Date from Orders WHERE CName='"+cn+"'"

c.execute(Q7)

bill=c.fetchall()

df=pd.DataFrame(bill,columns=['OrderNO.','Orders','Amount','Date'])

print(df)

print('\n','Total Amount=',df['Amount'].sum())

print('\n','\n')

a=int(input("Press 0 to Exit"))

if a==0:

order()

You might also like