the_prole the_prole - 2 months ago 17
Python Question

sqlite3.OperationalError: near "WHERE": syntax error

I want to update a series of columns Country1, Country2... Country 9 based on a comma delimited string of country names in column Country. I've programmed a single statement to accomplish this task.

cur.execute("\
UPDATE t \
SET Country1 = returnCountryName(Country,0),\
Country2 = returnCountryName(Country,1),\
Country3 = returnCountryName(Country,2),\
Country4 = returnCountryName(Country,3),\
Country5 = returnCountryName(Country,4),\
Country6 = returnCountryName(Country,5),\
Country7 = returnCountryName(Country,6),\
Country8 = returnCountryName(Country,7),\
Country9 = returnCountryName(Country,8),\
Country10 = returnCountryName(Country,9),\
WHERE Country IS NOT NULL\
;")


Howerver, I am getting the error

sqlite3.OperationalError: near "WHERE": syntax error
Press any key to continue . . .

Answer

You have to remove the comma from the last assignment:

Country10 = returnCountryName(Country,9),\

See also my answer to your original question