简体   繁体   English

Python sqlite3值错误

[英]Python sqlite3 Value Error

I have been getting this error and have stuck a few hours trying to understand what I am doing wrong. 我一直在收到此错误,并花了几个小时试图了解我在做什么错。 I have use this template for successfully importing into sqlite3 many many times in the past. 过去,我已经多次使用此模板成功导入sqlite3。

def TestImport():
   con = sqlite3.connect("test.db")
   con.execute("CREATE TABLE IF NOT EXISTS TestTable(ColA,ColB)")
   data=[('x','y')]
   stmt = "INSERT INTO TestTable VALUES(?,?)"
   con.execute(data,stmt)
   con.commit()
   con.close()

However this time I am getting this error: 但是这次我得到这个错误:

ValueError: operation parameter must be str or unicode

here 这里

con.execute(data,stmt)

它应该是

con.execute(stmt, data[0])

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM