【发布时间】:2014-08-09 18:32:42
【问题描述】:
我有这个代码sn-p:
import sqlite3
import cld
import langid
languagedata = [] #list for the returned data from database
n = -1
connector = sqlite3.connect("GERMANY.db")
selecter = connector.cursor()
selecter.execute(''' SELECT title FROM DATAGERMANY''')
for row in selecter: #iterate through all the rows in db
print (row)
lan = langid.classify("{}".format(row)) #identify the language
print (lan)
connector.execute('''update DATAGERMANY set title_abbreviation_langid=? , title_reliability_langid=? where id_db == ? ''',(lan[-2], lan[-1])
connector.commit() #save changes
connector.close()
我运行了 100 次,效果很好。我添加了另一个for loop,然后再次将其删除。所以我不应该更改代码中的任何内容。但现在我收到 connector.commit() 的 Invalid Syntax 错误。
这怎么可能?!
注意:没有关于错误的更多信息。
【问题讨论】:
-
回溯会很有用
-
@PadraicCunningham 什么是回溯? idl 高亮
connectorred -
您收到的完整错误代码
-
@PadraicCunningham
Invalid Syntax然后单词connector被突出显示为红色。不多了 -
所以当你运行代码时你没有得到正确的回溯输出?
标签: python sqlite error-handling syntax-error