-
Notifications
You must be signed in to change notification settings - Fork 0
/
Inventory.py
47 lines (43 loc) · 1.8 KB
/
Inventory.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#PYTHON MODULE: INVENTORY
import mysql.connector
from mysql.connector import errorcode
from datetime import date
from mysql.connector import (connection)
import os
def clrscreen():
print('\n' * 5)
def searchData():
try:
os.system('cls')
cnx = mysql.connector.connect(user='root', password='girlcode123', host='localhost', database='Inventory')
Cursor = cnx.cursor()
ProductCode = input("Enter Product Code to be searched from the Inventory : ")
query = ("SELECT * FROM Inventory where ProductCode = %s")
rec_srch = (ProductCode,)
Cursor.execute(query, rec_srch)
Rec_count = 0
for (ProductCode, ProductName, PurchaseDate, SalesDate, PurchasePrice, SalesPrice) in Cursor:
Rec_count += 1
print("=============================================================")
print("1.Product Code : ", ProductCode)
print("2.Product Name : ", ProductName)
print("3.Purchase Date : ", PurchaseDate)
print("4.Sales Date : ", SalesDate)
print("5.Purchase Price : ", PurchaseDate)
print("6.Sales Price : ", SalesPrice)
print("=============================================================")
if Rec_count%2 == 0:
input("Press any key continue")
clrscreen()
print(Rec_count, "Record(s) found")
Cursor.close()
cnx.close()
except mysql.connector.ERROR as err:
if err.errno == errorcode.ER_ACCESS_DENIED_ERROR:
print("Something is wrong with your user name or password")
elif err.errno == errorcode.ER_BAD_DB_ERROR:
print("Database does not exist")
else:
print(err)
else:
cnx.close()