I am creating a search bar where users can enter keywords such as movie title, imdb id, year of release to find a list of matching movies. I have a tabel called Movie looks something like this:
id title year runtime rating
tt1490017 The Lego Movie 2014 100 7.8
tt0111161 The Shawshank Redemption 1994 142 9.3
tt0068646 The Godfather 1972 175 9.2
I have a query that looks for movies containing the keyword(s) entered by the user that looks like this:
movies = db.session.query(Movie).filter_by(or_(id=searchkey,title=searchkey,year=searchkey))
where searchkey
is whatever is entered by the user in the search bar. However when I run this, it gives me the error saying that TypeError: or_() got an unexpected keyword argument 'id'
. Did I mess up my syntax or is there something else wrong? Would really appreciate your help.