I'm new to working with Flask and SQL, I am trying to create a simple front-end interface to deal with my database, I am using peewee as my ORM. This is my code:
```
def search(term):
items = Product.select().where(Product.name == term)
my_list = []
for item in items:
p_str = "Product: {}, Price: {}, Description: {}, Quantity in stock: {}".format(item.name,item.price, item.description, item.quant)
my_list.append(p_str)
return my_list
@app.route("/", methods=["GET", "POST"])
def index(name="Index"):
if request.method == "POST":
product = request.form["item"]
my_item = search(str(product))
return redirect(url_for("store", item=my_item))
return render_template("index.html", title=name)
@app.route("/store")
def store(name="Store"):
return render_template("store.html", title=name, items=request.args.getlist("item"))
```
The search function works fine if I run it in my python file, and the templates also work fine if I test using other variables e.g (a list of strings), but when I try to call it in my index function I get:
cursor.execute(sql, params or ())
peewee.OperationalError: no such table: product
127.0.0.1 - - [15/Jul/2022 10:12:25] "POST / HTTP/1.1" 500 -
I'm very new to the hole doing HTTP requests with python, so I'm not totally sure what I could try