Answer the question
In order to leave comments, you need to log in
Is it possible to pass an unknown number of values to a sqllite3 query, without crutches?
Is it possible to pass an unknown number of values to a sqllite3 query, without crutches?
cur.execute(
"""
DELETE from item
WHERE NOT name IN (?);
"""
(names,)
)
# вместо "?" должно подставится неизвестное количество параметров
Answer the question
In order to leave comments, you need to log in
Unfortunately no. The only way:
placeholders = ", ".join(["?"] * len(names))
sql = f"DELETE FROM item WHERE NOT name IN ({placeholders})"
cur.execute(sql, names)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question