Enhance luggage management: update new_part to accept pieces, add delete functionality, and log actions
This commit is contained in:
@@ -40,7 +40,7 @@ def new_part(cloth_type, weigth, pieces):
|
||||
logging.error("only ints allowed")
|
||||
else:
|
||||
cursor = connection.cursor()
|
||||
executed = "INSERT INTO luggage (clothes, weigth, pieces) VALUES (?, ?)"
|
||||
executed = "INSERT INTO luggage (clothes, weigth, pieces) VALUES (?, ?, ?)"
|
||||
executed_data = (cloth_type, weigth, pieces)
|
||||
cursor.execute(executed, executed_data)
|
||||
connection.commit()
|
||||
@@ -96,4 +96,12 @@ def fetch_piece(cloth_type):
|
||||
def fetch_all_pieces():
|
||||
cursor = connection.cursor()
|
||||
cursor.execute("SELECT sum(pieces) FROM luggage")
|
||||
pieces = cursor.fetchone()[0]
|
||||
pieces = cursor.fetchone()[0]
|
||||
logging.info("fetched all luggage pieces")
|
||||
return pieces
|
||||
|
||||
def delete(cloth_type):
|
||||
cursor = connection.cursor()
|
||||
cursor.execute("DELETE FROM luggage WHERE clothes = ?;", (cloth_type,))
|
||||
logging.critical(f"{cloth_type} was deleted")
|
||||
connection.commit()
|
||||
|
||||
Reference in New Issue
Block a user