From 7e0f9dd51ad97ffc8461b15aab8f90f87c7d6e57 Mon Sep 17 00:00:00 2001 From: agsNeto20 <37492761+agsNeto20@users.noreply.github.com> Date: Fri, 11 Dec 2020 22:09:10 +0000 Subject: [PATCH] Update database.py --- database.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/database.py b/database.py index 799d696..1af64fb 100644 --- a/database.py +++ b/database.py @@ -171,9 +171,13 @@ def remove_article(n_id): for i in n_id: itemid = i[0] - # TODO if client has movie dont remove - c.execute("DELETE FROM movies WHERE itemid = '" + str(itemid) + "'") - print("\n\tMovie removed successfully") + c.execute("SELECT * FROM rent WHERE movieid = '" + str(itemid) + "' AND timeavaible > 0") + result = c.fetchall() + if result: + print("\n\tCan't remove article because there are user(s) renting it") + else: + c.execute("DELETE FROM movies WHERE itemid = '" + str(itemid) + "'") + print("\n\tArticle removed successfully") conn.commit() conn.close()