Hi all,
I recently tried to create a search function which is supposed to display all possible results in a table even if the title is incomplete. However, I am using python variables and hence have to use colon notation to sub it into the sql command, however I also learnt about wildcards. How then do I use both of them without resulting in a conflict or error? My code goes something like this:
````
@app.route("/movie_results") #im using flask
def movie_results():
name = request.args.get("movie.title")
search_movie_statement = sqlalchemy.text('SELECT * FROM movies WHERE title LIKE :movie_title')
movie_specific = engine.execute(search_movie_statement, movie_title=name).fetchall()
if movie_specific is not None:
print(name)
return render_template("movie_specific.html", movie_specific=movie_specific, name=name)
if movie_specific is None:
return render_template("error2.html", message="No such movie.")
````
Thanks,
Cravan