partsdb

electronic parts inventory
git clone https://git.e1e0.net/partsdb.git
Log | Files | Refs

commit 806c8f8e4ad28cb649afa8ea3c502d8d21f6901f
parent b0f4cff8611557a2a1363d750bddad73b889303b
Author: Paco Esteban <paco@e1e0.net>
Date:   Sun, 14 Mar 2021 12:51:35 +0100

implement part delete

Diffstat:
Mdatabase.py | 8++++++++
MmyChips.py | 2+-
2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/database.py b/database.py @@ -73,6 +73,8 @@ INSERT_HISTORY_EVENT = """ """ UPDATE_PART_QTY_QUERY = "UPDATE parts SET quantity = ? WHERE id = ?" GET_PART_QTY = "SELECT quantity FROM parts where id = ?" +DELETE_PART_QUERY = "DELETE FROM parts WHERE id = ?" +DELETE_HISTORY_QUERY = "DELETE FROM parts_history WHERE part_id = ?" class PartsDB(): @@ -146,5 +148,11 @@ class PartsDB(): qty = qty + movement c.execute(UPDATE_PART_QTY_QUERY, (qty, part_id)) + def delete_part(self, part_id): + with self.conn: + c = self.conn.cursor() + c.execute(DELETE_HISTORY_QUERY, (part_id,)) + c.execute(DELETE_PART_QUERY, (part_id,)) + def close(self): self.conn.close() diff --git a/myChips.py b/myChips.py @@ -137,7 +137,7 @@ def get_part(part_id, files): def delete_part(part_id): - pass + db.delete_part(part_id) def adjust_stock(part_id, stock_mod, comment):