I'm having the following error:
File "sqldata/basetables/places.py", line 24, in update
sqldata.objs.c.execute("UPDATE places SET name='%s', matrix='%s', bans='%s', pop='%s' WHERE name='%s'" % (place.name,place.matrix,place.bans,place.pop,name))
sqlite3.OperationalError: near "bob": syntax error
Where I have:
>>> place.name
'room'
>>> place.matrix
[['bob', False, False], [False, False, False], [False, False, False]]
>>> place.bans
[]
>>> place.pop
[]
>>> name
'room'
For some reason the single quotes around bob
seem to be causing the error, since if I replace 'bob'
with True
it works, but the single quotes around room
do not cause any errors. What is the best approach to correct this? I can't replace 'bob'
with bob
, since I want a string there, not an object.
I tried the suggestions found here and here but the string remains the same. I also tried replacing 'bob'
for ''bob''
, u'''bob'''
, "bob"
, "'bob'"
, "\'bob\'"
. It all gives syntax error.
Removing the single quotes from the SQL query gives:
File "sqldata/basetables/places.py", line 24, in update
sqldata.objs.c.execute("UPDATE places SET name=%s, matrix=%s, bans=%s, pop=%s WHERE name=%s" % (place.name,place.matrix,place.bans,place.pop,name))
sqlite3.OperationalError: near ",": syntax error