Implement CRUD operations for luggage items: add, update, delete, and fetch functionalities; enhance logging and error handling

This commit is contained in:
Mabe
2026-08-28 21:02:25 +02:00
parent 79e0af79dc
commit c1931fae20
5 changed files with 216 additions and 40 deletions
+22 -21
View File
@@ -25,9 +25,9 @@ except Exception as e:
def insert():
clothe = input("How is the clothe called? ").upper()
weigth = float(input("The weigth please? "))
weight = float(input("The weight please? "))
pieces = int(input("How many pieces? ints only "))
db.new_part(clothe, weigth, pieces)
db.new_part(clothe, weight, pieces)
print("it is inserted")
time.sleep(3)
os.system('cls' if os.name == 'nt' else 'clear')
@@ -35,9 +35,9 @@ def insert():
def insert():
clothe = input("How is the clothe called? ").upper()
weigth = float(input("The weigth please? "))
weight = float(input("The weight please? "))
pieces = int(input("How many pieces? ints only "))
db.new_part(clothe, weigth, pieces)
db.new_part(clothe, weight, pieces)
print("it is inserted")
time.sleep(3)
os.system('cls' if os.name == 'nt' else 'clear')
@@ -45,26 +45,26 @@ def insert():
def update():
clothe = input("How is the clothe called? ").upper()
weigth = input("The weigth please? ")
weight = input("The weight please? ")
pieces = input("How many pieces? ints only ")
db.update_weigth(clothe, weigth)
db.update_weight(clothe, weight)
db.update_pieces(clothe, pieces)
print("it is updated")
time.sleep(3)
os.system('cls' if os.name == 'nt' else 'clear')
menu()
def get_weigth():
def get_weight():
clothe = input("How is the clothe called? ").upper()
weigth = db.fetch_weigth(clothe)
print(weigth)
weight = db.fetch_weight(clothe)
print(weight)
time.sleep(3)
os.system('cls' if os.name == 'nt' else 'clear')
menu()
def get_luggage_weigth():
weigth = db.fetch_luggage_weigth()
print(f"The luggage has a weigth of {weigth}g")
def get_luggage_weight():
weight = db.fetch_luggage_weight()
print(f"The luggage has a weight of {weight}g")
time.sleep(3)
os.system('cls' if os.name == 'nt' else 'clear')
menu()
@@ -92,11 +92,11 @@ def get_clothes():
os.system('cls' if os.name == 'nt' else 'clear')
menu()
def get_weigth_pieces():
def get_weight_pieces():
clothe = input("How is the clothe called? ").upper()
weigth = db.fetch_weigth(clothe)
weight = db.fetch_weight(clothe)
pieces = db.fetch_piece(clothe)
print(f"You have {pieces} of {clothe}. The weigth is {weigth}")
print(f"You have {pieces} of {clothe}. The weight is {weight}")
time.sleep(3)
os.system('cls' if os.name == 'nt' else 'clear')
menu()
@@ -133,17 +133,18 @@ def exit_programm():
time.sleep(0.75)
os.system('cls' if os.name == 'nt' else 'clear')
sys.exit()
os._exit(1)
def menu():
print("Menu")
print("1: Insert Item")
print("2: Update Item")
print("3: Get weigth of clothe")
print("4: Get weigth of luggage")
print("3: Get weight of clothe")
print("4: Get weight of luggage")
print("5: Get pieces of clothe")
print("6: Get pieces of luggage")
print("7: Get clothes")
print("8: Get weigth and pieces of clothes")
print("8: Get weight and pieces of clothes")
print("9: Delete Item")
print("0: EXIT")
choice = input("Type number here ")
@@ -155,9 +156,9 @@ def menu():
if choice == "2":
update()
if choice == "3":
get_weigth()
get_weight()
if choice == "4":
get_luggage_weigth()
get_luggage_weight()
if choice == "5":
get_pieces()
if choice == "6":
@@ -165,7 +166,7 @@ def menu():
if choice == "7":
get_clothes()
if choice == "8":
get_weigth_pieces()
get_weight_pieces()
if choice == "0":
exit_programm()
if choice == "9":