darksky
darksky

Reputation: 21039

Flask Update SQLite Record

Using Flask, I'm trying to implement HTTP PATCH. I am using SQLite.

Here's what I have:

if 'name' in data.keys():
    db.execute('UPDATE places SET name=%s WHERE id=%s', (str(data['name']), str(data_id)))

This yields the following error: OperationalError: near "%": syntax error

What is wrong with my parametrisaton? I've looked up a few examples that pretty much look like this. I tried adding a % before the parameters parenthesis and that is also failing. I also tried concatenating using +'s but that also doesn't work.

Upvotes: 3

Views: 2343

Answers (2)

ITJunkie
ITJunkie

Reputation: 3

Need a quote like this name='%s' by SQL syntax

Upvotes: 0

CL.
CL.

Reputation: 180161

In SQLite, parameter placeholders are not %s but ?.

Upvotes: 5

Related Questions