Computer Project
Computer Project
KALPETTA
DEPARTMENT OF COMPUTER
SCIENCE 2019-20
SUBMITTED BY:
1|Page
CERTIFICATE
Certified to be the bonafide record of project work done by
MANU KRISHNAN K (Roll no.24633441) of Class XII of
Kendriya Vidyalaya, Kalpetta during the year 2019-20.
Date:
2|Page
ACKNOWLEDGEMENT
I would like to express a deep sense of thanks & gratitude to
Mrs.Aneesa N Ali for guiding me immensely through the
course of the project. Her constructive advice & constant
motivation has been responsible for the successful
completion of this project.
My sincere thanks go to Dr.S S Dakua , Principal, Kendriya
Vidyalaya, Kalpetta , for his co-ordination in extending every
possible support for the completion of this project.
I thank my parents for their constant motivation and support.
I also thank my classmates for their timely help and support
for the completion of this project.
Last but not the least, I would like to thank all those who
directly or indirectly helped me towards the completion of
this project.
3|Page
CONTENTS
S.No TOPIC PAGE NO
1. Abstract 5
2. Coding 6-21
4. Output 24-35
5. Conclusion 36
6. Bibliography 37
4|Page
ABSTRACT
5|Page
CODING
import os
import mysql.connector
import datetime
now = datetime.datetime.now()
def product_mgmt():
while True:
if p == 1:
add_product()
if p == 2:
search_product()
if p == 3:
update_product()
if p == 4:
6|Page
delete_product()
if p == 5:
break
def purchase_mgmt():
while True:
if o == 1:
add_order()
if o == 2:
list_order()
if o == 3:
break
def sales_mgmt( ):
while True:
7|Page
if s == 1:
sale_product()
if s == 2:
list_sale()
if s == 3:
break
def user_mgmt():
while True:
if u == 1:
add_user()
if u == 2:
list_user()
if u == 3:
break
def create_database():
8|Page
mydb = mysql.connector.connect(host="localhost", user="root",password="123456",
database="MPS_Inv")
mycursor = mydb.cursor()
sql = "CREATE TABLE if not exists product(pcode int(4) PRIMARY KEY, pname char(30) NOT
NULL, price float(8,2), pqty int(4), pcat char(30));"
mycursor.execute(sql)
sql = "CREATE TABLE if not exists orders(orderid int(4)PRIMARY KEY, orderdate DATE,pcode
char(30) NOT NULL , pprice float(8,2),pqty int(4), supplier char(50), pcat char(30));"
mycursor.execute(sql)
sql = "CREATE TABLE if not exists sales(salesid int(4) PRIMARY KEY,salesdate DATE,pcode
char(30) references product(pcode),pprice float(8,2), pqty int(4),Total double(8,2));"
mycursor.execute(sql)
sql = "CREATE TABLE if not exists user (uid char(6) PRIMARY KEY,uname char(30) NOT NULL,
upwd char(30));"
mycursor.execute(sql)
9|Page
def list_database():
mydb = mysql.connector.connect(host="localhost",
user="root",password="123456",database="MPS_Inv")
mycursor = mydb.cursor()
mycursor.execute(sql)
for i in mycursor:
print(i)
def add_order():
mycursor = mydb.cursor()
now = datetime.datetime.now()
sql = "INSERT INTO orders (orderid, orderdate, pcode,pprice, pqty, supplier,pcat) values
(%s,%s,%s,%s,%s,%s,%s);"
oid = now.year+now.month+now.day+now.hour+now.minute+now.second
mycursor.execute(sql, val)
10 | P a g e
mydb.commit()
def list_order():
mycursor = mydb.cursor()
mycursor.execute(sql)
print("\t\t\tORDER DETAILS")
print("-"*85)
print("-" * 85)
for i in mycursor:
print(i[0], "\t", i[1], "\t", i[2], "\t", i[3], "\t", i[4], "\t", i[5], "\t", i[6])
print("-" * 85)
def db_mgmt( ):
while True:
11 | P a g e
if p == 1:
create_database()
if p == 2:
list_database()
if p == 3:
break
def add_product():
mycursor = mydb.cursor()
val = (code,)
mycursor.execute(search,val)
for x in mycursor:
cnt = x[0]
if cnt == 0:
val = (code,name,price,qty,cat)
12 | P a g e
mycursor.execute(sql,val)
mydb.commit()
else:
def update_product():
mycursor = mydb.cursor()
val = (qty,code)
mycursor.execute(sql,val)
mydb.commit()
def delete_product():
mycursor=mydb.cursor()
val = (code,)
13 | P a g e
mycursor.execute(sql, val)
mydb.commit()
print(mycursor.rowcount,"record(s) deleted");
def search_product():
while True:
if s == 1:
list_product()
if s == 2:
list_prcode(code)
if s == 3:
list_prcat(cat)
if s == 4:
break
14 | P a g e
def list_product():
mycursor = mydb.cursor()
mycursor.execute(sql)
for i in mycursor:
print("\t\t", i[0], "\t", i[1], "\t", i[2], "\t", i[3], "\t\t", i[4])
def list_prcode(code):
mycursor = mydb.cursor()
val = (code,)
mycursor.execute(sql, val)
15 | P a g e
print("\t\t", "-" * 47)
for i in mycursor:
print("\t\t", i[0], "\t", i[1], "\t", i[2], "\t", i[3], "\t", i[4])
def sale_product():
mycursor = mydb.cursor()
val = (pcode,)
mycursor.execute(sql,val)
for x in mycursor:
cnt = x[0]
if cnt != 0 :
val = (pcode,)
mycursor.execute(sql, val)
for x in mycursor:
print(x)
price = int(x[2])
pqty = int(x[3])
16 | P a g e
qty = int(input("Enter no of quantity :"))
val = (int(cnt)+1,datetime.datetime.now(),pcode,price,qty,total)
mycursor.execute(sql,val)
mycursor.execute(sql, val)
mydb.commit()
else:
else:
def list_sale():
mycursor = mydb.cursor()
mycursor.execute(sql)
17 | P a g e
print("-" * 80)
print("-" * 80)
for x in mycursor:
print(x[0], "\t", x[1], "\t", x[2], "\t\t", x[3], "\t\t", x[4], "\t\t", x[5])
print("-" * 80)
def list_prcat(cat):
mycursor = mydb.cursor()
print(cat)
val = (cat,)
mycursor.execute(sql, val)
clrscr()
for i in mycursor:
print("\t\t", i[0], "\t", i[1], "\t", i[2], "\t", i[3], "\t\t", i[4])
18 | P a g e
print("\t\t", "-" * 55)
def add_user():
mycursor = mydb.cursor()
mycursor.execute(sql, val)
mydb.commit()
def list_user():
mycursor = mydb.cursor()
mycursor.execute(sql)
clrscr()
print("\t\t\tUSER DETAILS")
19 | P a g e
print("\t\t", "-" * 27)
print("\t\t UID\t\tname")
for i in mycursor:
def clrscr():
print("\n"*5)
while True:
clrscr()
print("\t\t\t ****************\n")
print("\t\t 6. EXIT\n")
if n == 1:
product_mgmt()
if n == 2:
20 | P a g e
os.system('cls')
purchase_mgmt()
if n == 3:
sales_mgmt()
if n == 4:
user_mgmt()
if n == 5:
db_mgmt()
if n == 6:
break
21 | P a g e
MYSQL TABLE STRUCTURES
TABLE PRODUCT
TABLE ORDERS
22 | P a g e
TABLE SALES
TABLE USER
23 | P a g e
OUTPUT
24 | P a g e
25 | P a g e
26 | P a g e
27 | P a g e
28 | P a g e
29 | P a g e
30 | P a g e
31 | P a g e
32 | P a g e
33 | P a g e
34 | P a g e
35 | P a g e
CONCLUSION
36 | P a g e
BIBLIOGRAPHY
Computer Science with python - Sumita Arora
Computer Science with python - Preeti Arora
Geeksforgeeks.org
Stackoverflow.com
37 | P a g e