1

With python sqlite3, I'd like to something like

cursor.execute('SELECT * FROM songs WHERE filename LIKE "?%"', (key_string,))

so that I can use the key as a variable instead of having to hard code the pattern. But this does not work and gives me:

ProgrammingError: Incorrect number of bindings supplied. The current statement uses 0, and there are 1 supplied.

Please help.

1 Answer 1

2

Figured out the answer my self:

cursor.execute('SELECT * FROM songs WHERE filename LIKE ?', ('{}%'.format(key_string),))
Sign up to request clarification or add additional context in comments.

2 Comments

what is the key_string? is it the matching string?
@east.charm a string to use as a keyword

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.