I am trying to figure out how can I get this to work and this is a side project I decided to make apart from the studies on my own. What I need is to be able to search items in a category column by providing a string like "Mobile" and then I return a list of items in a particular category, but that is working for me for another functions.
I hope this is sufficient.
def search_ims_category_items(category):
with DatabaseConnection('inventory.db') as connection:
cursor = connection.cursor()
cursor.execute(f'SELECT * FROM inventory WHERE category = ?', (category,))
This is where the return should happen
def search_category_items():
category = input("Enter the category name you want to find: ")
items = database.search_ims_category_items(category)
for item in items:
print(
f"{item['product_name']} | {item['product_number']} | {item['category']} | ${item['price']} | ${item['discount']} | {item['quantity']}")
Much appreciated!
What I do is I execute the query where category needs to be like input category name from other function. Tried with %s, and other methods, but I cannot get this to work. And, I have checked Python docs before coming here, but can't quite figure this out.