basically i’m creating a webapp on flask, just a simple menu connected to a database, and i’m having issues with the variants of an item
that’s my db structure:
product_name | product_category | product_variants | product price | description
categories = get_db().execute("SELECT DISTINCT category FROM products ORDER BY category DESC").fetchall()
allDict = {}
for category in categories:
products = get_db().execute("SELECT name,variants,prices,description FROM products WHERE category=?", (category[0],)).fetchall()
allDict[category[0]] = products
return render_template("home.html", allDict=allDict)
but i have an issue, the product variants and price of the variant (only one price if is the same) are separed with a / symbol and i want to split them to have control over position and style with css cause they are separated elements
otherwise i have just a string and i can’t manipulate that
example
after i do this
products = get_db().execute("SELECT name,variants,prices,description FROM products WHERE category=?", (category[0],)).fetchall()
i get something like this: [('waffle', 'big/normal/baby', '5$/4$/3$', 'very good waffle')]
also i can’t create a column for every variant because idk how mutch variant can a product have
so what is the best solution in terms of performance?
tried already to use split method or transform the tuple as a list but I think there is a better way to handle this problem
8