This is my code :
import sqlite3
def delete_product(data):
with sqlite3.connect("main.db") as db:
cursor = db.cursor()
sql = "delete from Products where Name=?"
if cursor.rowcount <= 0:
print("The product {0} does not exist" .format(name))
if cursor.rowcount > 0:
cursor.execute(sql,data)
db.commit()
print("The product {0} has been delted successfully" .format(name))
if __name__ == "__main__":
name=input("Enter the name of the product you want to delete: >>")
data=(name,)
delete_product(data)
I want to check if the name actually exists in the database or not if it exists then delete it. if it doen't exist then print out an error. can anyone help me spot where the problem is