I have a database and i want to search in it with this HTML
<form action="/question/search" method="POST">
<input id="search" type="text" placeholder="Search.." name="search">
<button id="search" type="submit">🔍</button>
</form>
I get the data in my function
@app.route("/question/search",methods=["POST"])
def search():
search_result = request.form.get("search")
story = data_handler.get_search_result(search_result)
return render_template('search_resoult.html', stories=story)
but i just cant figure out the SQl for it i tried :
@database_common.connection_handler
def get_search_result(cursor,item):
my_sql = "SELECT * FROM question WHERE title LIKE %s OR message LIKE %s"
my_resoult = (item)
cursor.execute(my_sql, my_resoult)
resoult = cursor.fetchall()
return resoult
I just want to all the data that has my_result in the title or in the message. It always gives me this error:
TypeError: not all arguments converted during string formatting