【发布时间】:2016-09-20 05:05:25
【问题描述】:
我正在尝试将包含数据的列表插入到 .db 文件中。
下面是db文件的布局。
等级是一个整数
描述是TEXT
我有以下 Python 代码和 SQlite 查询,
我收到错误消息:
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Python27\lib\lib-tk\Tkinter.py", line 1536, in __call__
return self.func(*args)
line 136, in DB_Entry
top_ten.execute('INSERT INTO Top_Ten VALUES(?,?)', [range(1,11),SMH_LADDER[:10]],)
InterfaceError: Error binding parameter 0 - probably unsupported type.
下面是python代码:
def DB_Entry():
# Create a connection to the database.
connection = connect(database = "top_ten.db")
# Get a cursor on the database. This allows you to execute SQL
top_ten = connection.cursor()
top_ten.execute('INSERT INTO Top_Ten VALUES(?,?)', [range(1,11),SMH_LADDER[:10]],)
# Commit the changes to the database
connection.commit()
# Close the cursor.
top_ten.close()
# Close the database connection.
connection.close()
我正在尝试将 SMH_LADDER[:10] 的内容(它们是字符串)和范围(1,11)中的数字放入 db,但无法通过此错误消息!
以下是列表 SMH_LADDER[:10]
的格式
['String1','String2','String3','String4','String5','String6','String7','String8','String9','String10']
任何帮助将不胜感激!
【问题讨论】: