sqlite3.OperationalError:靠近“WHERE”:语法错误

时间:2016-09-25 19:40:14

标签: python sqlite

我想根据国家/地区列中逗号分隔的国家/地区字符串更新一系列列Country1,Country2 ... Country 9。我编写了一个语句来完成这项任务。

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,我收到了错误

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

1 个答案:

答案 0 :(得分:0)

您必须从上次分配中删除逗号:

Country10 = returnCountryName(Country,9),\

另请参阅my answer原始问题