I'm trying to get the IDs of the films from DB where category equals users input category, but for some reason I'm not able to do it. My code:
import sqlite3
#Connectin to DB
conn = sqlite3.connect('sakila.db')
c = conn.cursor()
#Checking if the connection to the DB is successful
if (conn):
print("Connection successful")
else:
print ("Connection unsuccessful")
kategorija=input("Enter the category: ")
c.execute("SELECT FID FROM film_list WHERE category=%s", (kategorija,))
film = c.fetchall()
#Removing duplicates
final_film = list(dict.fromkeys(film))
print(final_film)
The error i get: line 14, in c.execute("SELECT FID FROM film_list WHERE category=%s", (kategorija,)) sqlite3.OperationalError: near "%": syntax error
?, not%s. Your query should beSELECT FID FROM film_list WHERE category=?